Free Support Forum - groupdocs.com

Open another file on initialized viewer


#1

Hi.


I’m using GroupDocs.Annotation to open a PDF file with the Javascript code below. The file opens fine the first time.

But, using this same DIV, I want to open another document or change the document on this initialized viewer. I tried to invoke the same function again (passing a different fileId, but the document opened on the viewer didn’t change. No error occurred.

var annotationWidget = $(’#viewer-container’).groupdocsAnnotation({
localizedStrings : null,
thumbsImageBase64Encoded : undefined,
width : 0,
height : 0,
fileId : info.fileId,
docViewerId : ‘annotation-widget-doc-viewer’,
quality : 100,
enableRightClickMenu : false,
showHeader : true,
showZoom : true,
showPaging : true,
showPrint : false,
showFileExplorer : false,
showThumbnails : true,
showToolbar : false,
openThumbnails : true,
zoomToFitWidth : true,
zoomToFitHeight : true,
initialZoom : 100,
preloadPagesCount : 0,
enableSidePanel : false,
scrollOnFocus : true,
strikeOutColor : ‘#00000c’,
highlightColor : ‘#000017’,
underlineColor : ‘#FF0000’,
textFieldBackgroundColor : ‘#990000’,
enabledTools : 8191,
connectorPosition : 0,
saveReplyOnFocusLoss : false,
clickableAnnotations : true,
disconnectUncommented : false,
enableStandardErrorHandling : true,
strikeoutMode : 1,
undoEnabled : true,
anyToolSelection : true,
tabNavigationEnabled : false,
minimumImageWidth : 150,
areaToolOptions : {
pen : {
width : 1,
color : -65536,
dashStyle : 0
},
brush : {
color : -16711936
}
},
polylineToolOptions : {
pen : {
width : 1,
color : -65536,
dashStyle : 0
},
brush : {
color : -16711936
}
},
arrowToolOptions : {
pen : {
width : 1,
color : -65536,
dashStyle : 0
},
brush : {
color : -16711936
}
},
distanceToolOptions : {
pen : {
color : -16776961
}
},
sideboarContainerSelector : ‘div.comments_sidebar_wrapper’,
usePageNumberInUrlHash : false,
textSelectionSynchronousCalculation : true,
variableHeightPageSupport : true,
useJavaScriptDocumentDescription : true,
isRightPanelEnabled : false,
createMarkup : true,
use_pdf : ‘true’,
_mode : ‘annotatedDocument’,
selectionContainerSelector : “[name=‘selection-content’]”,
graphicsContainerSelector : ‘.annotationsContainer’,
userName : info.userName,
userId : info.userId
});

#2

Hello,


Thank you for your request. To achieve your goal you should follow this logic:

1. Initialize and open document as you do via adding Annotation JavaScript.
2. Then delete Annotation DIV with JS code - for example put Annotation DIV with code in to the one more DIV and then remove this div
3. Add same div with Annotation DIV and JS code with new file name
All these will regenerate Annotation and will send new requests for new document.

Best regards

#3

Thank you, Pavel. It worked.


Rafael

#4

Hello Rafael,


Glad to hear that.

Best regards.