JAVA Tech ViewONE JavaScript API User Manual

ViewONE JavaScript API Manual
Version 3.0
Last Updated: 04
Copyright Daeja Image Systems. All Rights Reserved.
Email: info@daeja.com
Web site: http://www.daeja.com
th
DAEJA IMAGE SYSTEMS
Contents
Introduction................................................................................................................................................7
The Applet user interface...........................................................................................................................8
ViewONE Standard...............................................................................................................................................................9
ViewONE Pro .....................................................................................................................................................................10
Mayscript parameter............................................................................................................................................................10
Apple Macintosh users (JavaScript)....................................................................................................................................10
Apple Macintosh users (HTML).........................................................................................................................................11
Setting up Windows 2003 server..............................................................................................................12
ViewONE JavaScript Overview ...............................................................................................................15
JavaScript Reference................................................................................................................................16
Security note: Change since ViewONE 3.0.99 Standard and 1.0.99 Pro............................................................................16
General Applet Control...................................................................................................................................... 17
isReady().............................................................................................................................................................................17
getVersion().........................................................................................................................................................................18
Opening documents and images........................................................................................................................ 19
openFile(filename, page).....................................................................................................................................................19
closeDocument().................................................................................................................................................................19
initializePageArray(numPages)...........................................................................................................................................19
setPageArray(filename, page).............................................................................................................................................19
openPageArray(page)..........................................................................................................................................................19
initializePageAndThumbsArray(numPages).......................................................................................................................21
setPageArray(filename, page).............................................................................................................................................21
setThumbsArray(filename, page)........................................................................................................................................ 21
openPageArray(page)..........................................................................................................................................................21
initializeDocumentArray(numDocs)...................................................................................................................................22
setDocumentArray(filename, index)...................................................................................................................................22
openDocumentArray() ........................................................................................................................................................22
openList(listFile, page)........................................................................................................................................................22
reloadList()..........................................................................................................................................................................23
openDoc(index)...................................................................................................................................................................23
nextDoc() prevDoc()...........................................................................................................................................................23
firstDoc().............................................................................................................................................................................23
lastDoc()..............................................................................................................................................................................23
getDocIndex() .....................................................................................................................................................................23
getNumDocs().....................................................................................................................................................................23
getNumPages()....................................................................................................................................................................23
setPage(page) ......................................................................................................................................................................24
getPage() .............................................................................................................................................................................24
nextPage() ...........................................................................................................................................................................24
previousPage().....................................................................................................................................................................24
setDescription(description) .................................................................................................................................................24
getDescription()...................................................................................................................................................................24
getDocReference() ..............................................................................................................................................................25
getCacheFile().....................................................................................................................................................................25
isCacheAccessFailed ().......................................................................................................................................................25
DAEJA IMAGE SYSTEMS
Specifying an Annotations File.......................................................................................................................... 26
setAnnotationFile(filename)................................................................................................................................................26
Saving documents and images........................................................................................................................... 27
save(filename).....................................................................................................................................................................27
savePage(filename)............................................................................................................. ................................................27
saveSelected(filename)........................................................................................................................................................27
isMultipageTif()..................................................................................................................................................................28
Document hyperlinks ......................................................................................................................................... 29
setHyperlink(url, dblClick) .................................................................................................................................................29
clearHyperlink()..................................................................................................................................................................29
setPDFPixelDepth(pixeldepth)............................................................................................................................................30
getPDFPixelDepth()............................................................................................................................................................30
setPDFResolution(resolution).............................................................................................................................................30
getPDFResolution().............................................................................................................................................................31
setAutoLimitPDFResolution(true/false)..............................................................................................................................31
isAutoLimitPDFResolution()..............................................................................................................................................31
setAutoLimitPDFMemoryValue(value)..............................................................................................................................31
getAutoLimitPDFMemoryValue()......................................................................................................................................32
COLD Viewing Options (Pro-Only).................................................................................................................. 33
setBackgroundImage(filename, pageNumber)....................................................................................................................34
initializeBackgroundImageArray(pages) ............................................................................................................................34
setBackgroundImageArrayItem(filename, index)...............................................................................................................34
useBackgroundImageArray(page).......................................................................................................................................34
setBackgroundImageEnabled(true/false) ............................................................................................................................35
isBackgroundImageEnabled().............................................................................................................................................35
Example JavaScript for opening a document with background templates..........................................................................35
Document Indexes (Pro-Only)...........................................................................................................................36
setIndexListFile(URL)........................................................................................................................................................36
Image.................................................................................................................................................................... 37
invert().................................................................................................................................................................................37
setInverted(true/false)..........................................................................................................................................................37
isInverted()..........................................................................................................................................................................37
setEnhance(true/false).........................................................................................................................................................37
isEnhance(true/false).......................................................................................................... .................................................38
setEnhanceMode(mode)......................................................................................................................................................38
getEnhanceMode()..............................................................................................................................................................38
setRotation(angle)............................................................................................................................................................... 38
initializeRotationArray(int size)..........................................................................................................................................39
setRotationArray(int angle, int page)..................................................................................................................................39
applyRotationArray()..........................................................................................................................................................39
getRotation() .......................................................................................................................................................................39
rotateClockwise()................................................................................................................................................................40
rotateCounterclockwise()....................................................................................................................................................40
rotate180()...........................................................................................................................................................................40
setFlip(mode) ......................................................................................................................................................................40
getFlip()...............................................................................................................................................................................41
setScale(scale).....................................................................................................................................................................41
getScale() ............................................................................................................................................................................41
getStates()............................................................................................................................................................................41
setStates(string states).........................................................................................................................................................42
zoomIn()..............................................................................................................................................................................42
DAEJA IMAGE SYSTEMS
zoomOut()...........................................................................................................................................................................42
zoom100()...........................................................................................................................................................................42
setZoom(zoom)...................................................................................................................................................................43
setZoomAndXYScroll(zoom, x, y).....................................................................................................................................43
zoomArea(x, y, width, height, highlight, seconds)..............................................................................................................43
setXYScroll(x, y) ................................................................................................................................................................43
setDraggingEnabled(true/false)...........................................................................................................................................44
isDraggingEnabled()...........................................................................................................................................................44
setBrightness(percent).........................................................................................................................................................44
resetBrightness() .................................................................................................................................................................44
getBrightness()....................................................................................................................................................................45
setContrast(percent) ............................................................................................................................................................45
resetContrast().....................................................................................................................................................................45
getContrast()........................................................................................................................................................................45
setLuminance(percent)........................................................................................................................................................46
resetLuminance().................................................................................................................................................................46
getLuminance()...................................................................................................................................................................46
getImageWidth().................................................................................................................................................................46
getImageHeight() ................................................................................................................................................................47
getXResolution().................................................................................................................................................................47
getYResolution().................................................................................................................................................................47
Viewing.....................................................................................................................................................48
setView(view).....................................................................................................................................................................48
getView() ............................................................................................................................................................................48
setAreaZoom(true/false)......................................................................................................................................................49
isAreaZoom()......................................................................................................................................................................49
toggleAreaZoom()...............................................................................................................................................................49
setMagnifier(true/false)....................................................................................................................................................... 49
setMagnifierInternal(true/false)...........................................................................................................................................50
isMagnifier() .......................................................................................................................................................................51
toggleMagnifier()................................................................................................................................................................51
setMagFactor()....................................................................................................................................................................51
getMagFactor()....................................................................................................................................................................51
setMagBounds(int x, int y, int width, int height).................................................................................................................51
setNewWindowVisible(true/false)......................................................................................................................................51
isNewWindowVisible().......................................................................................................................................................52
setImageForeColor(color)...................................................................................................................................................52
showImageForeColorDialog().............................................................................................................................................52
setImageBackColor(color)..................................................................................................................................................53
showImageBackColorDialog()............................................................................................................................................53
Labels................................................................................................................................................................... 54
initializeLabels(numLabels)................................................................................................................................................54
setLabel(pageLabel, pageLabelColor, thumbLabel, thumbLabelColor, labelNum) ...........................................................54
useLabels()..........................................................................................................................................................................54
clearLabels()........................................................................................................................................................................54
Selection and clipboard...................................................................................................................................... 55
selectPage(int pageNumber)................................................................................................................................................55
clearSelections()..................................................................................................................................................................55
copyPageToClipboard()......................................................................................................................................................55
getSelection() ......................................................................................................................................................................55
Printing................................................................................................................................................................ 56
printPage()...........................................................................................................................................................................56
DAEJA IMAGE SYSTEMS
printDocument()..................................................................................................................................................................56
printRange() ........................................................................................................................................................................56
printSelected().....................................................................................................................................................................57
printVisible().......................................................................................................................................................................57
printTransformed()..............................................................................................................................................................57
setPrintDialog(true/false)....................................................................................................................................................57
isPrintDialog().....................................................................................................................................................................58
setPrintCopies(integer)........................................................................................................................................................58
setPrinter(string)..................................................................................................................................................................58
setPrintHeader(headerString)..............................................................................................................................................59
setPrintAutoRotate (true/false)............................................................................................................................................60
Toolbars and Buttons......................................................................................................................................... 61
setScrollbars(true/false).......................................................................................................................................................61
isScrollbars().......................................................................................................................................................................61
setStatusBar(true/false) .......................................................................................................................................................61
isStatusBar()........................................................................................................................................................................61
setFileButtons(true/false)....................................................................................................................................................62
isFileButtons().....................................................................................................................................................................62
setImageButtons(true/false) ................................................................................................................................................63
isImageButtons().................................................................................................................................................................63
setPrintButtons(true/false)...................................................................................................................................................63
isPrintButtons()...................................................................................................................................................................64
setInvertButtons(true/false).................................................................................................................................................64
isInvertButtons() .................................................................................................................................................................64
setNewWindowButtons(true/false).....................................................................................................................................64
isNewWindowButtons()......................................................................................................................................................65
setViewButtons(true/false)..................................................................................................................................................65
isViewButtons() ..................................................................................................................................................................65
setAllButtons(true/false) .....................................................................................................................................................65
isAllButtons()......................................................................................................................................................................66
setPageButtons(true/false)...................................................................................................................................................66
isPageButtons()...................................................................................................................................................................66
toggleAdjustTool()..............................................................................................................................................................67
setAdjustToolVisible(OnOff)..............................................................................................................................................67
isAdjustToolVisible()..........................................................................................................................................................67
Menus and keys................................................................................................................................................... 68
setFileMenus(true/false)......................................................................................................................................................68
IsFileMenus()......................................................................................................................................................................68
setViewMenus(true/false) ...................................................................................................................................................69
isViewMenus()....................................................................................................................................................................69
setImageMenus(true/false)..................................................................................................................................................70
isImageMenus()...................................................................................................................................................................70
setPrintMenus(true/false)....................................................................................................................................................71
isPrintMenus().....................................................................................................................................................................71
setPageMenus(true/false)....................................................................................................................................................72
isPageMenus().....................................................................................................................................................................72
setSelectMenus(true/false)..................................................................................................................................................73
isSelectMenus()...................................................................................................................................................................73
setPreferenceMenus(true/false)...........................................................................................................................................74
isPreferenceMenus()............................................................................................................................................................74
setAllMenus(true/false)....................................................................................................................................................... 75
isAllMenus() .......................................................................................................................................................................75
setFileKeys(true/false) ........................................................................................................................................................75
DAEJA IMAGE SYSTEMS
isFileKeys().........................................................................................................................................................................75
setImageKeys(true/false).....................................................................................................................................................76
isImageKeys().....................................................................................................................................................................76
setPrintKeys(true/false).......................................................................................................................................................77
isPrintKeys() .......................................................................................................................................................................77
setViewKeys(true/false)......................................................................................................................................................77
isViewKeys().......................................................................................................................................................................78
setPageKeys(true/false).......................................................................................................................................................78
isPageKeys() .......................................................................................................................................................................78
setSelectKeys(true/false).....................................................................................................................................................78
isSelectKeys() .....................................................................................................................................................................79
setAllKeys(true/false)..........................................................................................................................................................79
isAllKeys()..........................................................................................................................................................................79
Timeout/User Idle Control................................................................................................................................. 80
setTimeout(seconds)............................................................................................................................................................80
getTimeout()........................................................................................................................................................................80
stopTimeout()...................................................................................................................................................................... 80
isTimedOut().......................................................................................................................................................................80
getTimeLeft()......................................................................................................................................................................81
wakeUp().............................................................................................................................................................................81
The Event Handler and Event Handling.......................................................................................................... 82
Events handler change in ViewONE Version 3..................................................................................................................83
Events ids and descriptions.................................................................................................................................................84
Event Handler example:......................................................................................................................................................87
Testing your Event Handler ................................................................................................................................................88
The MayScript tag...............................................................................................................................................................88

Introduction

ViewONE is a Java applet that extends your web b row ser so that y ou can vi ew, zoom, magnify, scroll, pan, rotate and print your images and image do cuments quickly and easily.
This document is the ViewONE JavaScript Manual and covers how to use and w hat options are available for the ViewONE JavaScript API.
This document is designed to be used in conjunction w ith the ViewONE H TML and Installation Manual.
(Please note: This manual does not cover the Jav ascript API for Anno tations, please see the Applet Annotations Configuration Manual)
For further information about ViewONE please consult the following documents…
ViewONE User Manual
ViewONE HTML and Installation Manual
ViewONE Annotations User Manual
ViewONE Annotations Installation HTML and JavaScript Manual
Various White Papers for in-depth analysis of specific a reas
Latest ViewONE release notes found at
http://www.daeja.com/pub/start/release.html
7777

The Applet user interface

File
Open,
Close and
Save
Toolbar
Toggle
Print Page, Document
and Page Range
Zoom Area, Zoom In, Zoom Out,
Magnify, Zoom 100%, Fit to Width,
Fit to Height, Best Fit, Rotate
Clockwise, Rotate
Counterclockwise, Rotate 180, Flip
Horizontally, Flip Vertically, Invert
and Help
New Window
Scroll to
First, Previous, Next and
Last Page
Vertical
scrollbar
Image Area
Drag mouse
to pan image
Document
Information
View Fullpage,
Thumbnails,
Two pages
Thumbs-left,
Thumbs bottom,
Thumbs right and
Thumbs top
Enhance mode
Help and progress
captions appear here
Horizontal scrollbar
Adjust Brightne ss
8888
Installing ViewONE
HTML:
To install ViewONE on your web site you must first download the ‘Update’ zip file from the Daeja web site. This can be found by visiting www .daeja.com/pub/start/downloads.html
After unzipping the downloaded file you should have a directory named “v1files”. Thi s directory contains the essential files required to install and use ViewONE.
Copy all files found in the “v1files” directory to your web server, pre ferably in a separa te directory similarly named.
ViewONE Standard
If you have downloaded ViewONE Standard (with or without the Print Accelerator or Annotations optional modules), then to use ViewONE on your w eb site, se tup a w eb pa ge containing the following HTML…
<APPLET CODEBASE = “.” ARCHIVE = “ji.jar” CODE = “ji.applet.jiApplet.class” NAME = “ViewONE” WIDTH = “100%” HEIGHT = “97%” HSPACE = “0” VSPACE = “0” ALIGN = “middle” MAYSCRIPT=”true”> <PARAM NAME=“cabbase” VALUE=“ji.cab”> </APPLET>
9999
ViewONE Pro
If you have downloaded ViewONE Pro (with or without the Print Accelerator, Annota tions, DjVu, PDF or other optional modules), then to use View ONE Pro on your w eb site, setup a web page containing the following HTML…
<APPLET CODEBASE = “.” ARCHIVE = “ViewONE.jar” CODE = “start.jiViewONE.class” NAME = “ViewONE” WIDTH = “100%” HEIGHT = “97%” HSPACE = “0” VSPACE = “0” ALIGN = “middle” MAYSCRIPT=”true”> <PARAM NAME=“cabbase” VALUE=“ViewONE.cab”> </APPLET>
In each case, you must change the “codebase ” value to poin t to the loca tion of the ‘v1 files’ directory that contains ViewONEs resource files (i.e. ji.jar, ji.cab and other .v1 files).
The codebase parameter specifies the location of the ji .jar, ji.cab and o ther file s relative
to the location o f the H TM L p age . So in th is cas e it speci fies the “c ur ren t d ir ect ory ” w hi ch i s “.”
(Note: PARAM NAME=cabbase” is required for M icrosoft Explorer users) . Our downloadable demos include examples to assist y ou.
Mayscript parameter
When using JavaScript it is important to include the M AYSCRIPT parameter (see both HTML samples above). This parameter is an enabl er for the JavaScript interface. Without it, calls to JavaScript will not work.
Apple Macintosh user s (Jav aScr ipt)
Depending on the version of the operating sy stem us ed by Apple M acintosh co mputers, JavaScript may or may not operate correctly .
Apple MacOS 8 and 9 computers utiliz e Apples Java en gine known as M RJ (M acintosh Runtime Java). This particular Java engine did not have full support for JavaS cript to Java Applets and so the JavaScript API will not operate with M RJ.
Apple MacOS X (10.x) computers utilize Apples upd ated Java 2 engine w hich does include support for JavaScript to Java API’s.
10
1010
10
Apple Macintosh users (HTML)
ViewONE comes with a digital certificate which is required to permit the applet to print and provide local caching. ViewONE is also Java 1.1.5 compliant.
Apple Macintosh 9 users will need to use IE4.5 (or l ater) and Apple M acintosh X (10.x ) can use IE5, Netscape 7 or Mozi lla.
IE uses Apples run-time Java (called MRJ). Since the release o f IE4.5 Apple h ave released several versions of MRJ. It is recommended that use rs use M RJ version 2.2 or later. Netscape 7 and Mozilla browsers use Java 1.4 .x which is suppo rted by V iew ONE.
Using ViewONE Standard on IE for A pple Macintosh
To use IE (MRJ Java) you will hav e to ensure y our HTML speci fies the alternativ e archive file…
ARCHIVE = “jis.jar”
Using ViewONE Pro on IE for A pple Macintosh
To use IE (MRJ Java) you will hav e to ensure y our HTML speci fies the alternativ e archive file…
ARCHIVE = “ViewONEdsa.jar”
We have produced a demo w hich uses so me JavaScript to de tect Apple M ac users and make appropriate changes automatically.
Demos are available at http://www.daeja.com/pub/start/downloads.html
11
1111
11

Setting up Windows 2003 server

If your server is running Windows 2003 with IIS 6, you w ill hav e to add two file extensions to your w eb site “M IME Types” .
Unlike previous Windows servers, Windows 2003 p ermits only a limi ted number of file extensions by default, all others must be enabled ma nually using the IIS consol e.
The additional mime types required to operate ViewONE are “.v1” and “.ant”. Note: if they are not added to IIS 6 then ViewONE will display messa ges during start-up that files w ith these extensions could not be found).
Both file extensions should be set to the mime type “application/octet-stream”, as follows..
Open up IIS 6 console, then right-click on the top w eb space en try to highlight “Properties”…
12
1212
12
Click on the properties menu to display the properties dialog…
Click on the MIME Type button to display the M IM E Type dialog…
Use the New button to add two new M IM E types…
13
13
1313
Click OK until you return back to the main console dialog. Ri ght click once a gain on the main web spa c e e nt ry . Cl ick o n th e Re sta rt IIS me n u to ac ti v ate the n ew M IM E Ty pe s.
14
1414
14

ViewONE JavaScript Ov erview

The ViewONE Javascript API offers an alternative mechanism to confi gure and control the ViewONE applet.
In many cases the use of the Javasc ript API will not be required simply becaus e most configuration parameters can be implemented using simple H TML (see ViewONE HTML manual).
However, where a more dynamic operation is requir ed, for exam ple, where it i s desired to configuration parameters during the operation of View ONE, perhaps to chan ge a document without reloading a web page, rotate a page, inver t etc then the JavaScript API is ideal.
Additionally, traditional web viewing applications habitually reload a web page in order to view or change the currently view ed image/document.
But with ViewONE’s extensive Image/Document open/close JavaScrip t API methods it is possible to avoid web page refreshing entirely. This can result in significant pe rformance improvements since all delays due to web page reh freshing (and therefore Java En gine reloading and applet restarting) are avoided.
Daeja has produced white paper specifically addres sing per formance tuning w hich covers the area of web page refreshing and apple t reloading. Please v isit Daeja’s w eb site to download white papers www.daeja.com
.
Browser Note : Please note, some browsers are case sensitive and so we adv ise the use of method
names in exactly the same case as spe cified in this manual. Failure to adhere to this may result in methods not being called correctly.
15
1515
15

JavaScript Reference

The JavaScript examples in this manual do not refer to their use in any particul ar context. The examples could be used within functions o f a Ja vaScript program o r directly as event handlers to buttons, hyper-links etc. Our web site illustrates such u ses; al ternatively refer to an appropriate JavaScript guide.
Filenames and hyperlink addresses are ex pressed using th e In ternet URL addr ess format (Uniform Resource Locator), e.g. “http://mysite/myimage.tif”. If any part of the address before “myimage.tif” is not included then the applet w ill assume a base addre ss that is the same as the applet location (the codebase) .
With the exception of filenames and hyperlink addresses, all parameters a re case insensitive.
Security note: Change sin ce Vie wONE 3. 0. 99 Standa rd and 1.0. 99 P ro
Some Javascript methods are disabled by default an d can only be enabled by setting the JavaScripExtensions HTML parameter set to tru e .
<PARAM NAME=“JavaScriptExtensions” VALUE=“true”>
e.g. This is to prevent unauthorized users from attempting to manipulate View ONE through
Javascript methods in or d er to obtain ac cess to sec ure information/documents/annotations.
The methods that are restricted in this manner are clearly marked w ithin this document.
16
16
1616

General Applet Control

Method:

isReady()

E.g. var ready = ViewONE.isReady(); This method returns true if the applet as completed initialization. If JavaScript is used to open a documen t during HTM L page initialization then this method
is useful in determining when ViewONE has fully initialized (prior to opening the document).
Browsers normally initialize Applets in parallel to HTML initialization and so it may be necessary to use this method to synch ronize calls to View ONE. Also, ViewONE itsel f runs thru an initialization phase in parallel to the loading of a web page.
Note on “object not found” message… If you receive an “object not found” message while making this (or any JavaScript
calls) then it is because the applet has not been started by the browser (ViewONE has not even had a chance to perform it’s own initialization). This message is produced by the browser (not the applet).
The solution is to add some JS code to the call of isReady() which handles object not found (or any use of JavaScript with ViewONE), as follows…
17
1717
17
var appletReady = false; var doc = parent.frames.main.document; //(or just 'document' if it's not in a frame)
if (doc.ViewONE) {
appletReady = doc.ViewONE.isReady();
}
if (appletReady) {
//do something
}
Method:
The “if (doc.ViewONE)” line will result in false if the applet has yet to be started. If you still have problems then you may want to make use of the “OnError” JavaScript
statement that allows you to set up your own error h andler. Your error handler w ill then be called when a JavaScript problem is encountered s uch as abov e. E.g..
onerror = errorHandler;
//you code to do whatever you need to do… then…
function errorHandler() {
//if we get here it is probably because a call has been made //to the applet before the browser has had time to initialize it //it can therefore be ignored
}

getVersion()

E.g. var version = ViewONE.getVersion(); Returns a String value representing the product version.
18
1818
18

Opening documents and images

Method:
Method:

openFile(filename, page)

E.g. ViewONE.openFile(“myimages.tif”, 1); Specifies the filename and initial page of the document to be view ed. This filename can specify either the filename relative to the code base (as abo ve) or the
full URL. The code base is specified in the HTM L code for the applet (see previous example). An example of a full URL is as follows…
E.g. ViewONE.openFile(“http://mysite/myimages.tif”, 1);

closeDocument()

E.g. ViewONE.closeDocument(); Closes an open document. NOTE: Closing the open document also resets annotations, annotation templates and
background images.
Method Group:
initializePageArray (numPages) setPageArray(filename, page) openPageArray(page)
E.g. ViewONE.initializePageArray(3); ViewONE.setPageArray(“page1.tif”, 0); ViewONE.setPageArray(“page2.tif”, 1); ViewONE.setPageArray(“page3.tif”, 2); ViewONE.openPageArray(1); This method group specifies the number files (pages) in a list, then specifies each file
(each one representing a successive pa ge of the do cument), then ope ns the ‘ assembled’ document at page 1. Note the page array begins at array element z ero.
19
19
1919
Initializing the page and thumb arrays causes a ‘soft’ close to be pe rformed, i.e. the cu rrent document is closed and the annotation source , templates and ba c kground images are reset if a document is currently open. If no docu ment is cu rrently open, then the close and reset is not performed.
20
2020
20
Method Group:
initializePageAndThumbsArray(numPages) setPageArray(filename, page) setThumbsArray(filename, page) openPageArray(page)
E.g. ViewONE.initializePageAndThumbsArray(3); ViewONE.setPageArray(“page1.tif”, 0); ViewONE.se tThu mbsA rra y (“p a ge1- t.ti f” , 0 ); ViewONE.setPageArray(“page2.tif”, 1); ViewONE.se tThu mbsA rra y (“p a ge2- t.ti f” , 1 ); ViewONE.setPageArray(“page3.tif”, 2); ViewONE.se tThu mbsA rra y (“p a ge3- t.ti f” , 2 ); ViewONE.openPageArray(1); These methods are similar to the previous. They speci fy the number files (pages) in a list,
and then specify a separate file for each page and a thumbnail file for that page. The final method then opens the “assembled” document at page 1 . Note, the pa ge array begins at array element zero.
In some instances, it may be advantageous to have separate files for the thumbnails to assist in browsing of thumbnails (smaller files are quicker to dow nload and v iew ).
Initializing the page anf thumb arrays causes a ‘soft’ close to be pe rformed, i.e. the cu rrent document is closed and the annotation source , templates and ba c kground images are reset if a document is currently open. If no docu ment is cu rrently open, then the close and reset is not performed.
21
2121
21
Method Group:
initializeDocumentA rray(numDocs) setDocumentArray( filenam e, index) openDocumentArray()
E.g. ViewONE.initializeDocumentArray(3); ViewONE.setDocumentArray(“doc1parameters.txt”, 0); ViewONE.setDocumentArray (“doc2parameters.txt”, 1); ViewONE.setDocumentArray (“doc3parameters.txt”, 2); ViewONE.openDocumentArray(1); This method group specifies the number docu ments to open in a multi-docu ment session ,
then specifies the parameter file for each do cument ( each one representing a successiv e document), then opens the ‘assembled’ document list at document t1 . Note the docu ment array begins at array element zero.
For information about using document paramater files, please refer to the ViewONE HTML Installation Manual; look up the section on the “Doc<N>” H TML parameter .
Method:
Initializing the page anf thumb arrays causes a ‘soft’ close to be pe rformed, i.e. the cu rrent document is closed and the annotation source , templates and ba c kground images are reset if a document is currently open. If no docu ment is cu rrently open, then the close and reset is not performed.

openList(listFile, page)

E.g. ViewONE.openList(“mylist/list.txt”, 1); This method offers and alternative option to the page array methods above. It allow s a file
to be supplied which contains a list of pa ges. This is useful for very large documents becau se i t removes the need to deal w ith an a rray
in JavaScript . It can also be used to keep the H TML cons tant, by changing the sour ce list instead o f
changing the HTML between different documen ts. (Separate files for thumbnails are not available for this option).
22
2222
22
Method:
Method:
Method Group:

reloadList()

E.g. ViewONE.reloadList() This method forces the list used with the openList() method to be reloaded an d the
document to be re-opened. It will reload the list file from source (i.e. the w eb s erver) each time, so if it has changed then the changes w ill be picked up.

openDoc(index)

E.g. ViewONE.openDoc(2) This method applies only when the “doc<N>” H TML paramete r is used ( see HTML
manual). The value of “index” represents the associ ated “doc<N>” parameter. Therefore, the above example will cause ViewONE to open the secon d do cument in the list (i.e., that specified by the “doc2” HTM L parameter).
nextDoc() prevDoc() firstDoc() lastDoc() getDocIndex() getNumDocs()
Method:
These are convenience methods that can be used in place o f the “openDoc” method described above.

getNumPages()

E.g. var numPages = ViewONE.getNumPages(); Gets the number of pages in the current d ocument ( an integer).
23
23
2323
Method:
Method:
Method:

setPage(page)

E.g. View ON E.se tP a ge( 2) ; Sets the current page number (an integer).

getPage()

E.g. var page = ViewONE.getPage(); Returns the current page number as an inte ger.

nextPage()

E.g. ViewONE.nextPage();
Method:
Method Group:
Convenience method to view the next page (c urrent page + 1 )

previousPage()

E.g. ViewONE.previousPage(); Convenience method to view the previous pa ge (current page - 1).
setDescription(description) getDescription()
E.g. var desc = ViewONE.getDescription(); ViewONE.setD esc ri ptio n(“ my Do c”); Gets or sets the description for the document. The d escription is used w hen opening the
document in ViewONE, “Opening docXYZ…” or “Opening docXYZ, page 2….” will be displayed in the status bar.
24
2424
24
Method:
Method:

getDocReference()

E.g. Var ref = ViewONE.getDocReference(); Gets the document reference for the document.

getCacheFile()

E.g. var file = ViewONE.getGetCacheFile(); Returns a String value representing the local filename of the displayed image. If the file was loaded locally then this value will be the actual local image file. If the file w as
loaded from a web server then this value w ill be the local ‘cached’ v ersion of the image file. *Important: This file must not be locked during read operations (or deleted, renamed.
moved etc), as the applet will not be able to con tinue to use it and unp redictable results may occur.
isCacheAccessFailed
()
Returns true i f access to the Vi ewON E cache fails. Vie wON E may atte mpt to write to more than one location before and will only return true from this call if all attempts to w rite have failed.
25
2525
25

Specifying an A nnot ations File

Method:

setAnnotationFile(filename)

E.g. ViewONE.setAnnotationFile(“http://mysite/myannotations.ant”); This method sets the annotation file and must be ca lled be fore
any of the open methods
described above. If the current document is closed after this method has been called, the anno tation file will
be reset. To avoid this, close the current document be fore setting the annotation file, as closing of the current document can be a side effect o f calling other JavaScrip t methods, for example, ‘initializePageArray’.
e.g. viewONE.setAnnotationFile("http://...annotations.ant"); viewONE.openFile(“http://... m ydocument.t if” , 1);
or
viewONE.closeDocument(); viewONE.setAnnotationFile("http://...annotations.ant"); viewONE.initializePageArray(2);
viewONE.setPageArray("http://....page1.tiff", 0);
viewONE.setPageArray("http://....page2.tif", 1);
viewONE.openPageArray(1);
26
2626
26

Saving documents and images

Method:
Method:

save(filename)

E.g. View ON E.sa ve (“ c:/ te mp/i ma ge .ti f” ); Saves the cu rre n t d ocu me nt ( mul ti-pa g e ti ffs ), o r c u rr en t pa ge ( mul ti- fi le d o cum ents ) to the
specified filename. If filename is null, either the save dialog is displayed or, if a server side save co mponent
has been specified, the image is sent to the serv er side componen t. Note: The save operation does not recreate the source file, it merely copies the sou rce file
to the specified destination and renames it to the sp ecified filename.

savePage(filename)

E.g. ViewONE.savePage(“c:/temp/page.tif”); Saves the current page to the speci fied filename.
Method:
If filename is null, either the save dialog is displayed or, if a server side save co mponent has been specified, the image is sent to the serv er side componen t.
If the document is a multi-page tif then this method will extract the current page from the source tif file, and create a new tif file containing only the cu rrent page.

saveSelected(filenam e)

E.g. View ON E.sav e Sel ect ed (“c: /te mp /sel ec ted .tif”); Saves the current selected pages of a multi-page tif document. If filename is null, either the save dialog is displayed or, if a server side save co mponent
has been specified, the image is sent to the serv er side componen t. Note: this method is for use only with multi-page tif documents. If you are v iewing a multi-
file document then it is not possible to save selected pages from that docu ment ex cept by individually calling the savePage() method for each page that you w ant to sav e. You may find isMultipageTif() and getSelected() methods useful to call before calling this method.
27
2727
27
Loading...
+ 61 hidden pages