Tips For Success

Having the best tools for document imaging is only half of the equation. Our Tech Tips are designed to provide you with valuable information to help succeed by achieving faster results with RasterMaster SDKs or FlexSnap viewers. New time-saving tips are added monthly - you can receive them through Imaging News or our Tech Tips RSS feed.

Tech Tip: Using JavaScript to Call into FlexSnap Applet API Methods

The FlexSnap family of web viewers gives you the ability to manipulate a loaded image from outside the viewer. Public methods are provided in FlexSnap to allow external access to functionality such as zooming, opening documents, and navigating pages. See the method summary below for the public methods and functionality available.

The following applet tag and html link provide an example of using JavaScript to call into the FlexSnap Applet API:

< applet name="FlexSnap" code="com.snowbound.snapplet.applets.SnapServApplet"

</applet>

 

< a href="#" onClick="javascript:FlexSnap.zoomIn();">Zoom In</a><br>

In the example above, clicking on the Zoom In hyperlink will allow you to zoom in on the current document.

The method summary below describes the public methods available that give you external access to FlexSnap’s functionality .

Note : The rotate(int degrees) , invert() , flipVertical() , and flipHorizontal() methods will be available in the October 2006 release of FlexSnap.

Method Summary

 void

firstPage ()
Opens the first page of the current document.

 void

fitWidth ()
Zooms the current page width to fit the width of the FlexSnap Image panel .

 void

fitWindow ()
Zooms the current page to fit the size of the FlexSnap Image panel.

 void

flipHorizontal ()
Flips the image horizontally.

Available in the October 2006 release of FlexSnap.

 void

flipVertical ()
Flips the image vertically.

Available in the October 2006 release of FlexSnap.

 void

invert ()
Inverts the image.

Available in the October 2006 release of FlexSnap.

 void

lastPage ()
Opens the last page of the current document.

 void

nextPage ()
Opens the next page of the current document.

 void

openFile (String filename)
Opens the specified document in FlexSnap.

 void

previousPage ()
Opens the previous page of the current document.

 void

rotate (int degrees)
Rotates the image.

Available in the October 2006 release of FlexSnap.

 void

showMagnifierWindow ()
Opens the Magnifier window.

 void

showPage (int index)
Opens the specified page of the current document.

 void

zoomIn ()
Zooms in the view of the image.

 void

zoomOut ()
Zooms out the view of the image.

 void

zoomPercent ()
Zooms the current page to the specified percentage.

Method Detail


firstPage

public void firstPage()

Opens the first page of the current document. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.firstPage();">First Page</a><br>


fitWidth

public void fitWidth()

Zooms the current page width to fit the width of the FlexSnap Image panel. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.fitWidth();">Fit Width</a><br>


fitWindow

public void fitWindow()

Zooms the current page to fit the size of the FlexSnap Image panel. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.fitWindow();">Fit Window</a><br>


flipHorizontal

public void flipHorizontal()

Flips the image horizontally. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.flipHorizontal();">Flip Image Horizontally</a><br>


flipVertical

public void flipVertical()

Flips the image vertically. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.flipVertical();">Flip Image Vertically</a><br>


invert

public void invert()

Inverts the colors of the image. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.invert();">Invert Image Colors</a><br>


lastPage

public void lastPage()

Opens the last page of the current document. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.lastPage();">Last Page</a><br>


nextPage

public void nextPage()

Opens the next page of the current document. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.nextPage();">Next Page</a><br>


openFile

public void openFile(String filename)

Opens the specified document in FlexSnap. In the case where there are multiple windows open, the file opens in the primary FlexSnap Window. In FlexSnap Applet, name is the full local file path, or URL to the document. In FlexSnap: SI, name is the document name, or documentKey to be passed to the servlet. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.openFile("'snowbound.tif');">snowbound.tif</a>
<br>


previousPage

public void previousPage()

Opens the previous page of the current document. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.previousPage();">Previous Page</a><br>


rotate

public void rotate(int degrees)

Rotates the image. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.rotate(90);">Rotate 90 Degrees</a><br>


showMagnifierWindow

public void showMagnifierWindow()

Opens the Magnifier window. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.showMagnifierWindow();">Show Magnifier Window</a><br>


showPage

public void showPage(int index)

Opens the specified page of the current document. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.showPage(3);">Page 3</a><br>


zoomIn

public void zoomIn()

Zooms in the view of the image. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.zoomIn();">Zoom In</a><br>


zoomOut

public void zoomOut()

Zooms out the view of the image. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.zoomOut();">Zoom Out</a><br>


zoomPercent

public void zoomPercent(int percent)

Zooms the current page to the specified percentage. In the case where there are multiple windows open, this action is performed on the primary FlexSnap window. This method is part of the FlexSnap API. The following is an example JavaScript link to call this method:

<a href="#" onClick="javascript:FlexSnap.zoomPercent(150);">Zoom to 150 Percent</a><br>

Parameter

percent - The desired zoom percentage.