Which product are you using?
PDF.js Express Plus
PDF.js Express Version
8.7.4
Detailed description of issue
After saving annotated and merged pdf to database, note/comments aren’t rendered/visible when reopening pdf in viewer.
Expected behaviour
Notes/comments should be visible in comment/note pane.
Does your issue happen with every document, or just one?
This issue happens with every document
Link to document
I cannot provide a link to any of the affected pdfs
Code snippet
function instantiatePdfViewer(element) {
WebViewer({
path: ‘WebViewer/lib’, // path to the PDFTron ‘lib’ folder on your server
licenseKey: ‘Insert commercial license key here after purchase’,
highContrastMode: true,
}, document.getElementById(element))
.then(instance => {
const docViewer = instance.docViewer;
const annotManager = instance.annotManager;
annotManager.setCurrentUser(userName);
//const { docViewer, annotManager, CoreControls } = instance;
var FitMode = instance.FitMode;
instance.setFitMode(FitMode.FitWidth);
// call methods from instance, docViewer and annotManager as needed
// you can also access major namespaces from the instance as follows:
// const Tools = instance.Tools;
// const Annotations = instance.Annotations;
//Add header button that will get file data on click
instance.setHeaderItems(header => {
header.push({
type: 'actionButton',
img: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3zm3-10H5V5h10v4z"/></svg>',
//img: 'icon-header-zoom-in-line',
title: 'Save pdf markup to Visispecs Server',
onClick: async () => {
const doc = docViewer.getDocument();
var docId = doc.getDocumentId();
const xfdfString = await annotManager.exportAnnotations({ links: false, widgets: false });
//const options = { xfdfString: xfdfString };//, flatten: true };
const data = await doc.getFileData({});
const blob = new Blob([data], { type: 'application/pdf' });
const formData = new FormData();
formData.append('xfdf', xfdfString);
formData.append('file', blob);
// Process the file
const response = await fetch('https://api.pdfjs.express/xfdf/merge', {
method: 'post',
body: formData
}).then(resp => resp.json());
const { url, key, id } = response;
// Download the file
const mergedFileBlob = await fetch(url, {
headers: {
Authorization: key
}
}).then(resp => resp.blob())
var promise = getBase64(mergedFileBlob);
promise.then(function (result) {
// Do something with blob...
saveMarkupToVSServer(result, docId);
});
}
});
});
docViewer.on('documentLoaded', () => {
// call methods relating to the loaded document
//var htmlDiv = document.getElementById('pdfviewer');
//tabsContent['pdfviewer'] = htmlDiv;
});
docViewer.on('documentUnloaded', () => {
// remove doc from opened docs dictionary openedDocInfo
var doc = docViewer.getDocument();
var docId = doc.getDocumentId();
//openedDocInfo[docId]
//removeByAttr(openedDocInfo, 'cklistId', docId);
});
});
}