Home  • Download  • Register Now!  • Benefits  • Help  • Testimonials  • Samples  • Screenshots  • Awards  • Forum  • Convert Documents Online  • Print2Flash APIs  • Print2Flash vs. FlashPaper  • Contact Us
 Help Contents

Print2Flash Document API Functions

Below is the description of each Print2Flash Document Application Programming Interface function.
 
Signature Parameters Return value Comments
Navigation in the document
getCurrentPage() None The number of the currently displayed page Retrieves the number of the currently displayed page as shown in Go To Page text box
setCurrentPage(page) page - the number of the page to go to. Should be between 1 and the value returned by getNumberOfPages function None Moves document view to the specified page and makes it the current page as if the user entered a page number in Go To Page text box
NextPage() None None Displays the next document page as if Next Page button were pressed by the user
PreviousPage() None None Displays the previous document page as if Previous Page button were pressed by the user
getVisibleArea() None VisibleArea object describing the current visible area of the document Returns an object describing the current visible area of the document. You can use the return value to do one of the following:
  • Pass to setVisibleArea. This can be useful if the same document is being viewed on multiple computers, and you want to keep the visible areas in sync.
  • Compare with a previous value returned by getVisibleArea using equals method to determine if the visible area has been changed.
setVisibleArea (area:VisibleArea) area - VisibleArea object returned from a getVisibleArea function call None Adjusts the currently visible page/zoom/scroll/rotation to match the visible area described by the area object.
getScrollPosition() None Point object representing current scroll position Returns the current document scroll position
setScrollPosition (pos:Point) pos - new position Point object None Sets the current document scroll position to the value represented by pos parameter. Coordinates in pos object must be between 0 and the values returned by getMaxScrollPosition function
getMaxScrollPosition() None Point object representing maximum scroll position Returns the maximum document scroll position. Note that this value may be modified if document zoom level or rotation angle is changed
enableScrolling(enable) enable - flag specifying whether to enable scrolling. If true, scrolling is enabled; if false, scrolling is disabled None Enables or disables scrolling the document by user. If scrolling is disabled, scrollbars are not active, dragging mode  does not work, and scrolling with keyboard and mouse wheel is disabled.
NavBack() None • true if navigation was successful
• false otherwise
Function returns to the previous position in the document as if Back button were pressed. Function returns false if there is no previous position in the navigation history.
This function is available only for Flash documents.
NavForward() None • true if navigation was successful
• false otherwise
Function returns back to the next position in the document as if Forward button were pressed. Function returns false if there is no next position in the navigation history.
This function is available only for Flash documents.
scrollLine(lineNumber) lineNumber - the number of lines to scroll by None This function scrolls the document by the specified number of lines. This number can be either positive or negative. Positive values make the document scroll up, while negative values scroll it down.
This function is available only for Flash documents.
goToLinkTarget(url, window) url - URL of the document or bookmark to open
window - window or HTML frame into which the document should load
• true if navigation was successful
• false otherwise
This function either opens a new web document in the specified window or navigates to the document bookmark.
If url parameter is a string of the form anchor:bmname, the documents scrolls to the bookmark with a name of bmname. The window argument is ignored in this case. If bmname is not a valid bookmark name in the document, no action is taken and false is returned. See Hyperlinks for more information.

Zooming in and out

getCurrentZoom() None The current document zoom level in percent Retrieves the current document zoom level as shown in Zoom text box
setCurrentZoom(zoom) zoom:
• "width" - fit width
• "page" - fit page
• Number - scale to specified percentage
None Sets the current document zoom level to either a specified percentage if you passed a number as zoom argument or scales the document so as to fit width or page

Toolbar control

getCurrentTool() None • "move" if drag tool is active
• "select" if text selection tool is active
Returns the currently active tool.
setCurrentTool(tool) tool:
• "move" (drag tool)
• "select" (text selection tool)
None Makes the given tool the active tool as if the user pressed Drag or Select Text button
setControlVisibility(mask) mask -a bitwise combination of flags corresponding to controls to display None Hides or displays part of the user interface in the  document. The mask should be a bitwise combination of flags detailed in INTERFACE_OPTION Enumeration topic.
setLanguage(language) language - language code None Changes toolbar hint language. Possible parameter values are discussed in the help topic on Language property of Profile object.
adjustToolbarColor (hue, saturation, brightness, contrast) hue - hue adjustment value. Valid values are from -180 to 180
saturation - saturation adjustment value. Valid values are from -100 to 100
brightness - brightness adjustment value. Valid values are from -100 to 100
contrast - contrast adjustment value. Valid values are from -100 to 100
None Adjusts toolbar button and control color. This allows changing toolbar colors to a certain degree. Some useful parameter combinations can be found in the help topic on ColorAdjustment property of Profile object. For example, to change toolbar colors to green you should use this call:

adjustToolbarColor(-180,38,-4,0)

This function is available only for Flash documents.

Search

(These functions are available only for Flash documents)

SearchText(text) text - text to search for true if text was found and false - otherwise Searches for the next occurrence of text string in the document text as if Search button were pressed by the user. If this function is called for the first time or with another text value as in previous call, the search starts from the document beginning. On contrary, if this function is called with the same text value as in previous call, the search is continued from the previously found location. To make search start from the beginning for the same text value, call ResetTextSearch function before search 
findNext() None true if text was found and false - otherwise Searches for the text in the Search text box. The search begins from the end of the current selection. To make search start from the beginning of the document, call ResetTextSearch function before search 
ResetTextSearch() None None Resets text search so that the next search conducted by SearchText function always starts from the beginning of the document. Calling of this function is recommended before each new search
getFindText() None Text in the Search box Returns the text in the Search text box as a string
setFindText(text) text -text to set in the Search text box None Sets the text in the Search text box to a text value.

Text selection

getTextSelectionRange() None SelectionRange object Returns an object describing the current text selection. If no text is selected, this function returns null.
setTextSelectionRange (sel:SelectionRange) sel - the object describing the text selection None Selects the given range of text. You may pass null to deselect all the text.
getSelectedText() None Selected text Returns the selected text as a string. If no text is selected, an empty string is returned.

Other functions

getNumberOfPages() None The total number of pages in the document Retrieves the total number of pages in the document as shown in Total Pages indicator
getLoadedPages() None The total number of pages loaded so far in the document Retrieves the total number of pages loaded and shown so far in the document. The returned value can be between 0 and the value returned by getNumberOfPages function.
getPage(page) page - the number of page The MovieClip class or SVGDocument class nstance of the specified page Flash documents: Returns a reference to the MovieClip class instance representing the specified page image. The function should be called only after the needed page is already loaded (see onPageLoaded event) and is available only from Flash or Flex.
HTML5 documents: Returns a reference to the SVG document class instance representing the specified page image.
You may use this reference to perform additional operations on the page movie clip: drawing, listening on events, etc. 
OpenHelpPage() None None Opens the Print2Flash document interface help page as if Help button were pressed by the user
OpenInNewWindow() None None Opens the document once again in a separate browser window as if Open In New Window button were pressed by the user
printTheDocument() None None Prints the document as if Print button were pressed by the user
printTheDocument2 (showDialog, startPage, endPage, scaleMode) • showDialog:Boolean - specifies if the Print Options dialog should be shown before printing;
• startPage:Number - the number of the first page to be printed. The parameter is optional; default value is 1;
• endPage:Number - the number of the last page to be printed. The parameter is optional; default value is the number of the last page of the document;
• scaleMode:String - specifies how the page should be scaled regarding the paper size. It can be:
  • "noscale" - no scaling is performed;
  • "fit" - fit (reduce or enlarge) the page image to fit the paper; auto-rotate the image if necessary.
The parameter is optional; default value is the last value selected by the user in the Print Options dialog.
None Prints the document with the specified printing options. Parameters correspond to the options shown in the Print Options dialog. This function is available only for ActionScript 3 Flash documents. See How to Print the Converted Document on the Printer? for more information.
Rotate() None None Rotates all document pages by 90 degrees clockwise as if Rotate button were pressed by the user
setFullScreen(fullScreen) fullScreen:Boolean - specifies if full screen mode should be activated (true) or deactivated (false) None Switches the Flash Player into full screen mode or back into normal mode.
setSize(width, height) width - width of the document movie;
height
- height of the document movie
None Sets the Print2Flash document movie size to the specified width and height.
This function is available from Flash or Flex only. See Using Print2Flash Document API from other Applications to learn how to set document movie size from other applications.
This function is available only for Flash documents.
setVisiblePages(from,to) from - the number of the first page to show,
to - the number of the last page to show
None Makes visible only the document pages numbered between from and to parameters. Other pages are hidden and cannot be scrolled by user. Note that if you make visible only certain pages, the document behaves as if there were fewer pages in it. For example, getNumberOfPages function would return less than actual number of pages.