Hi Oscar
Thank you for the quick response.
I have recorded one video and i explained my issue clearly in the attached video.
it has low quality video, for uploading purpose i have compressed the file to low quality. please convert that video to MP4 and watch.
Below are the details i am sharing as per your comments
*** When you “open any other document”, how did you open it? (If you opened a file programmatically, please send me your code)**
we configured PDFTron UI in one of the LWC component and when component lifecycle method called renderedcallback method we are initilizing the webviewer and we are calling loaddocument method to load the file.below is the code for this,
uiInitialized = false;
renderedCallback() {
if (this.uiInitialized) {
return;
}
this.uiInitialized = true;
Promise.all([loadScript(this, libUrl + “/webviewer.min.js”)])
.then(() => {
this.initUI();
})
.catch(console.error);
}
initUI() {
var myObj = {
libUrl: libUrl,
fullAPI: true,
namespacePrefix: “”
};
const viewerElement = this.template.querySelector(“div”);
const viewer = new PDFTron.WebViewer(
{
path: libUrl, // path to the PDFTron ‘lib’ folder on your server
custom: JSON.stringify(myObj),
pdftronServer: “https://rimsmart1.azurewebsites.net”,
config: myfilesUrl + "/config.js",
fullAPI: this.fullAPI,
enableFilePicker: true
// l: 'YOUR_LICENSE_KEY_HERE',
},
viewerElement
);
viewerElement.addEventListener("ready", () => {
this.iframeWindow = viewerElement.querySelector("iframe").contentWindow;
});
}
@api loadDocumentFromBox(docData) {
console.log("coming here loadDocumentFromBox");
let docContentURL = "https://api.box.com/2.0/files/";
let authToken = "Bearer " + docData.authToken;
if (docData.isRenditionAvailable) {
docContentURL = docContentURL + docData.docRenditionExternalID + "/content";
} else if (docData.docExternalID) {
docContentURL = docContentURL + docData.docExternalID + "/content?version=" + docData.docVersionExternalID;
} else {
docContentURL = docContentURL + docData.docID + "/content";
}
console.log("docContentURL:", docContentURL);
this.iframeWindow.postMessage(
{
type: "BOX_DOCUMENT",
docContentURL: docContentURL,
authToken: authToken,
asUser: docData.userID,
fileName: docData.fileName,
isRenditionAvailable: docData.isRenditionAvailable,
docId: docData.docID,
recordId:this.recordId,
},
"*"
);
}
When we called loadDocumentFromBox, it is passing data to the iframe window recieve message event handled in config.js file, there we are loading the file in webviewer. below is the code for loading the document,
window.addEventListener(“message”, receiveMessage, false);
function receiveMessage(event) {
if (event.isTrusted && typeof event.data === ‘object’) {
switch (event.data.type) {
case ‘BOX_DOCUMENT’:
event.target.readerControl.loadDocument(event.data.docContentURL, {
filename: event.data.fileName,
cacheKey : Math.random().toString(36).substring(1),
customHeaders: {
Authorization: event.data.authToken,
‘as-user’: event.data.asUser
},
withCredentials: true
})
if(!event.data.isRenditionAvailable){
readerControl.disableElements([“toolbarGroup-Annotate”]);
hideannotationtabelements();
}
window.recordId = event.data.recordId;
break;
default:
break;
}
}
}
*** The 2 PDFs that you are using**
-If your application is open to the public, can you provide an access?
Sorry, our application is not in production.
if not, what’s the version of WebViewer you are using? Are there any errors under the browser console when you see this issue? Also please send me all related JavaScript code to this issue
this issue is replicated when we import annotation from external resource like DB or excel.
for import we are using below code
let XFDFData = event.data.data;
if(XFDFData !== undefined && XFDFData !== null && XFDFData !== “”){
let annotobj = JSON.parse(event.data.data);
if(annotobj.annotationList && annotobj.annotationList.length>0 && annotobj.annotationList[0].annotationdetail){
var annotManager = readerControl.docViewer.getAnnotationManager();
let XFDFString = {…annotobj.annotationList[0]}.annotationdetail;
annotManager.importAnnotations(XFDFString);
}
Please let us know any quick solution for this is much apreciated.
Thank you again for the quick response and i waiting for your response.
Thanks
Vijaykumar L S