Frameworks
Integrations
Mendix
SharePoint
Default UI
Modular UI
AnnotationManager
Annotation Types
Customize
Version 11
Version 10
v10.12
v10.11
v10.10
v10.9
v10.8
v10.7
v10.6
v10.5
v10.4
v10.3
v10.2
v10.1
v10.0
Version 8
v8.12
v8.11
v8.10
v8.9
v8.8
v8.7
v8.6
v8.5
v8.4
v8.3
v8.2
v8.1
v8.0
Version 7
Version 6
v6.3
v6.2
v6.1
v6.0
Version 5
Version 4
Version 3
Version 2
WebViewer Server
WebViewer BIM
Whereas the WebViewer instance is the entry point to the WebViewer SDK, the DocumentViewer is the main object responsible for the interaction with the viewing of a loaded document. The main APIs and events are focused around the viewing of the document.
In this guide, we will show you some common APIs that work with the document through the use of the DocumentViewer object. You can then apply these to get page information for a printing process or programmatically starting a text search for key terms.
To get a Document
object representing the currently loaded document, the DocumentViewer provides the getDocument
function. With the document object, you can interact directly with the document.
To read the number of pages of a loaded document, the DocumentViewer provides a getPageCount
function. This is often used in for loops to loop through pages. This API is also availble on the Document
class.
When scrolling or changing pages is available to a user, you can check which page they are on using the getCurrentPage
DocumentViewer API. The current page number may also be necessary when calling other APIs like rotatePages
to rotate the current page.
When scrolling or changing pages is available to a user, you can change the page that the user is on programmatically. This could be in response to clicking a button or perhaps going back to where a user last left off. This is done using the setCurrentPage
API.
A textSelected
event can be triggered from selecting text but it may be necessary to fetch the selected text outside of this event. This can be done with the getSelectedText
API.
If you need to know the location of the text, then getSelectedTextQuads
will give you a quad/rectangle representing the location and size of the selection.
Initiating a text search through the DocumentViewer offers finer control over the regular search. You may also be interested in searching with a regular expression which is entirely possible with textSearchInit
API.
Go deeper with the document APIs by reading on how to get the file data or manipulate the document further.
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales