Classes
Events
-
onAnnotationMenuPress
-
This function is called when an annotation menu item passed in to overrideAnnotationMenuBehavior is pressed.
Type:
functionOptional.
Source: DocumentView.js line 421
Parameters:
Name Type Description annotationMenuConfig.AnnotationMenuthe menu item that has been pressed.
annotationsArray<object>An array of
{id: string, pageNumber: number, type: string, screenRect: object, pageRect: object}objects.idis the annotation identifier andtypeis one of the Config.Tools constants.screenRectwas formerly calledrect.Both rects are represented with
{x1: number, y1: number, x2: number, y2: number, width: number, height: number}objects.Example
<DocumentView onAnnotationMenuPress = {({annotationMenu, annotations}) => { console.log('Annotation menu item', annotationMenu, 'has been pressed'); annotations.forEach(annotation => { console.log('The id of selected annotation is', annotation.id); console.log('The page number of selected annotation is', annotation.pageNumber); console.log('The type of selected annotation is', annotation.type); console.log('The screenRect of selected annotation is', annotation.screenRect); console.log('The pageRect of selected annotation is', annotation.pageRect); }); }} /> -
onAnnotationsSelected
-
This function is called when an annotation(s) is selected.
Type:
functionOptional.
Source: DocumentView.js line 604
Parameters:
Name Type Description annotationsArray<object>array of annotation data in the format
{id: string, pageNumber: number, type: string, screenRect: {x1: number, y1: number, x2: number, y2: number, width: number, height: number}, pageRect: {x1: number, y1: number, x2: number, y2: number, width: number, height: number}}, representing the selected annotations.typeis one of the Config.Tools constants.screenRectwas formerly calledrect.Example
<DocumentView onAnnotationsSelected = {({annotations}) => { annotations.forEach(annotation => { console.log('The id of selected annotation is', annotation.id); console.log('It is in page', annotation.pageNumber); console.log('Its type is', annotation.type); }); }} /> -
onAnnotationChanged
-
This function is called if a change has been made to an annotation(s) in the current document.
Note: When an annotation is flattened, it also gets deleted, so both onAnnotationChanged and onAnnotationFlattened are called.
Type:
functionOptional.
Source: DocumentView.js line 636
Parameters:
Name Type Description actionstringthe action that occurred (add, delete, modify)
annotationsArray<object>array of annotation data in the format
{id: string, pageNumber: number, type: string}, representing the annotations that have been changed.typeis one of the Config.Tools constantsExample
<DocumentView onAnnotationChanged = {({action, annotations}) => { console.log('Annotation edit action is', action); annotations.forEach(annotation => { console.log('The id of changed annotation is', annotation.id); console.log('It is in page', annotation.pageNumber); console.log('Its type is', annotation.type); }); }} /> -
onFormFieldValueChanged
-
This function is called if a change has been made to form field values.
Type:
functionOptional.
Source: DocumentView.js line 658
Parameters:
Name Type Description fieldsArray<object>array of field data in the format
{fieldName: string, fieldType: string, fieldValue: any}, representing the fields that have been changedExample
<DocumentView onFormFieldValueChanged = {({fields}) => { fields.forEach(field => { console.log('The name of the changed field is', field.fieldName); console.log('The type of the changed field is', field.fieldType); console.log('The value of the changed field is', field.fieldValue); }); }} /> -
onAnnotationFlattened
-
This function is called if an annotation(s) has been flattened in the current document.
Type:
functionOptional.
Source: DocumentView.js line 685
Parameters:
Name Type Description annotationsArray<object>array of annotation data in the format
{id: string, pageNumber: number, type: string}, representing the annotations that have been changed.typeis one of the Config.Tools constantsidreturned via the event listener can be null.Example
<DocumentView onAnnotationFlattened={({annotations}) => { annotations.forEach(annotation => { console.log('The id of changed annotation is', annotation.id); console.log('It is in page', annotation.pageNumber); console.log('Its type is', annotation.type); }); }} /> -
onBookmarkChanged
-
This function is called if a change has been made to user bookmarks.
Type:
functionOptional.
Source: DocumentView.js line 1194
Parameters:
Name Type Description bookmarkJsonstringthe list of current bookmarks in JSON format
Example
<DocumentView onBookmarkChanged = {({bookmarkJson}) => { console.log('Bookmarks have been changed. Current bookmark collection is', bookmarkJson); }} /> -
onBehaviorActivated
-
This function is called if the activated behavior is passed in to overrideBehavior
Type:
functionOptional.
Source: DocumentView.js line 483
Parameters:
Name Type Description actionConfig.Actionsthe action which has been activated.
dataobjectA JSON object that varies depending on the action.
If action is
Config.Actions.linkPress, data type is{url: string}.If action is
Config.Actions.stickyNoteShowPopUp, data type is{id: string, pageNumber: number, type: string, screenRect: {x1: number, y1: number, x2: number, y2: number, width: number, height: number}, pageRect: {x1: number, y1: number, x2: number, y2: number, width: number, height: number}}typeis one of the Config.Tools constants,screenRectwas formerly calledrect.Example
<DocumentView onBehaviorActivated = {({action, data}) => { console.log('Activated action is', action); if (action === Config.Actions.linkPress) { console.log('The external link pressed is', data.url); } else if (action === Config.Actions.stickyNoteShowPopUp) { console.log('Sticky note has been activated, but it would not show a pop up window.'); } }} /> -
onExportAnnotationCommand
-
This function is called if a change has been made to annotations in the current document. Unlike onAnnotationChanged, this function has an XFDF command string as its parameter. If you are modifying or deleting multiple annotations, then on Android the function is only called once, and on iOS it is called for each annotation.
Known Issues
On iOS, there is currently a bug that prevents the last XFDF from being retrieved when modifying annotations while collaboration mode is enabled.
Type:
functionOptional.
Source: DocumentView.js line 933
Parameters:
Name Type Description actionstringthe action that occurred (add, delete, modify)
xfdfCommandstringan xfdf string containing info about the edit
annotationsarrayan array of annotation data. When collaboration is enabled data comes in the format
{id: string}, otherwise the format is{id: string, pageNumber: number, type: string}. In both cases, the data represents the annotations that have been changed.typeis one of the Config.Tools constants.Example
<DocumentView onExportAnnotationCommand = {({action, xfdfCommand, annotations}) => { console.log('Annotation edit action is', action); console.log('The exported xfdfCommand is', xfdfCommand); annotations.forEach((annotation) => { console.log('Annotation id is', annotation.id); if (!this.state.collabEnabled) { console.log('Annotation pageNumber is', annotation.pageNumber); console.log('Annotation type is', annotation.type); } }); }} collabEnabled={this.state.collabEnabled} currentUser={'Pdftron'} /> -
onLayoutChanged
-
This function is called when the layout of the viewer has been changed.
Type:
functionOptional.
Source: DocumentView.js line 754
Example
<DocumentView onLayoutChanged = {() => { console.log('Layout has been updated.'); }} /> -
onLongPressMenuPress
-
This function is called if the pressed long press menu item is passed in to overrideLongPressMenuBehavior.
Type:
functionOptional.
Source: DocumentView.js line 345
Parameters:
Name Type Description longPressMenuConfig.LongPressMenuthe menu item that has been pressed.
longPressTextstringthe selected text if pressed on text, empty otherwise
Example
<DocumentView onLongPressMenuPress = {({longPressMenu, longPressText}) => { console.log('Long press menu item', longPressMenu, 'has been pressed'); if (longPressText !== '') { console.log('The selected text is', longPressText); } }} /> -
onTabChanged
-
The function is activated when a tab is changed.
This API is meant for tab-specific changes. If you would like to know when the document finishes loading instead, see the onDocumentLoaded event.
Type:
functionOptional.
Source: DocumentView.js line 1743
Parameters:
Name Type Description currentTabstringThe file path of current tab's document
Example
<DocumentView multiTabEnabled={true} onTabChanged={({currentTab}) => { console.log("The current tab is ", currentTab); }} /> -
onDocumentLoaded
-
This function is called when the document finishes loading.
Type:
functionOptional.
Source: DocumentView.js line 173
Parameters:
Name Type pathstringExample
<DocumentView onDocumentLoaded = {(path) => { console.log('The document has finished loading:', path); }} /> -
onDocumentError
-
This function is called when document opening encounters an error.
Type:
functionOptional.
Source: DocumentView.js line 189
Parameters:
Name Type errorstringExample
<DocumentView onDocumentError = {(error) => { console.log('Error occured during document opening:', error); }} /> -
onPageChanged
-
This function is called when the page number has been changed.
Type:
functionOptional.
Source: DocumentView.js line 206
Parameters:
Name Type Description previousPageNumberintthe previous page number
pageNumberintthe current page number
Example
<DocumentView onPageChanged = {({previousPageNumber, pageNumber}) => { console.log('Page number changes from', previousPageNumber, 'to', pageNumber); }} /> -
onPageMoved
-
This function is called when a page has been moved in the document.
Type:
functionOptional.
Source: DocumentView.js line 1722
Parameters:
Name Type Description previousPageNumberintthe previous page number
pageNumberintthe current page number
Example
<DocumentView onPageMoved = {({previousPageNumber, pageNumber}) => { console.log('Page moved from', previousPageNumber, 'to', pageNumber); }} /> -
onScrollChanged
-
This function is called when the scroll position has been changed.
Type:
functionOptional.
Source: DocumentView.js line 224
Parameters:
Name Type Description horizontalnumberthe horizontal position of the scroll
verticalnumberthe vertical position of the scroll
Example
<DocumentView onScrollChanged = {({horizontal, vertical}) => { console.log('Current scroll position is', horizontal, 'horizontally, and', vertical, 'vertically.'); }} /> -
onTextSearchStart
-
This function is called immediately before a text search begins, either through user actions, or function calls such as findText.
Type:
functionOptional.
Source: DocumentView.js line 1266
Example
<DocumentView onTextSearchStart = {() => { console.log('Text search has started'); }} /> -
onTextSearchResult
-
This function is called after a text search is finished or canceled.
Type:
functionOptional.
Source: DocumentView.js line 1304
Parameters:
Name Type Description foundbooleanwhether a result is found. If false, it could be caused by not finding a matching result in the document, invalid text input, or action cancellation (user actions or cancelFindText)
textSelectionobjectthe text selection, in the format
{html: string, unicode: string, pageNumber: number, quads: [[{x: number, y: number}, {x: number, y: number}, {x: number, y: number}, {x: number, y: number}], ...]}. If no such selection could be found, this would be nullQuads indicate the quad boundary boxes for the selection, which could have a size larger than 1 if selection spans across different lines. Each quad have 4 points with x, y coordinates specified in number, representing a boundary box. The 4 points are in counter-clockwise order, though the first point is not guaranteed to be on lower-left relatively to the box.
Example
<DocumentView onTextSearchResult = {({found, textSelection}) => { if (found) { console.log('Found selection on page', textSelection.pageNumber); for (let i = 0; i < textSelection.quads.length; i ++) { const quad = textSelection.quads[i]; console.log('selection boundary quad', i); for (const quadPoint of quad) { console.log('A quad point has coordinates', quadPoint.x, quadPoint.y); } } } }} /> -
onLeadingNavButtonPressed
-
This function is called when the leading navigation button is pressed.
Type:
functionOptional.
Source: DocumentView.js line 157
Example
<DocumentView onLeadingNavButtonPressed = {() => { console.log('The leading nav has been pressed'); }} /> -
onToolChanged
-
This function is called when the current tool changes to a new tool
Type:
functionOptional.
Source: DocumentView.js line 1226
Parameters:
Name Type Description previousToolConfig.Tools|stringthe previous tool (one of the Config.Tools constants or "unknown tool"), representing the tool before change
toolConfig.Tools|stringthe current tool (one of the Config.Tools constants or "unknown tool"), representing the current tool
Example
<DocumentView onToolChanged = {({previousTool, tool}) => { console.log('Tool has been changed from', previousTool, 'to', tool); }} /> -
onUndoRedoStateChanged
-
This function is called when the state of the current document's undo/redo stack has been changed.
Type:
functionOptional.
Source: DocumentView.js line 1477
Example
<DocumentView onUndoRedoStateChanged = {() => { console.log("Undo/redo stack state changed"); }} /> -
onZoomChanged
-
This function is called when the zoom scale has been changed.
Type:
functionOptional.
Source: DocumentView.js line 240
Parameters:
Name Type Description zoomdoublethe current zoom ratio of the document
Example
<DocumentView onZoomChanged = {(zoom) => { console.log('Current zoom ratio is', zoom); }} /> -
onZoomFinished
-
This function is called when a zooming has been finished. For example, if zoom via gesture, this is called on gesture release.
Type:
functionOptional.
Source: DocumentView.js line 257
Parameters:
Name Type Description zoomdoublethe current zoom ratio of the document
Example
<DocumentView onZoomFinished = {(zoom) => { console.log('Current zoom ratio is', zoom); }} />