Hi,
Regarding
I have tried as per comment but annotations not showing
Hi,
It looks like you are opening a different document than you started with? Here is my code that works:
var xfdf = await annotManager.exportAnnotations({ links: false, widgets: false });
var fileData = await docViewer.getDocument().getFileData({});
// var blob = new Blob([fileData], {type: 'application/pdf'});
var data = new FormData();
data.append('xfdf', xfdf);
data.append('file', 'http://africau.edu/images/default/sample.pdf');
data.append('license','');
// Process the file
var response = await fetch('https://api.pdfjs.express/xfdf/merge', {
method: 'post',
body: data
}).then(resp => resp.json());
var { url, key, id } = response;
// Download the file
var mergedFileBlob = await fetch(url, {
headers: {
Authorization: key
}
}).then(resp => resp.blob())
instance.loadDocument(mergedFileBlob);
Dear Logan,
Please check
Hi there,
Do you have disableFlattenedAnnotations
set in the constructor by chance? This would disable those annotations being drawn.
I cannot reproduce your issue. If you could send me a code sample of how you are saving/loading the document, as well as how you are loading webviewer, that would help.
Thanks,
Logan
Hi,
This is the code i have used.
WebViewer({
disableFlattenedAnnotations: true,
path: '/medc/lib',
licenseKey: '', // optional
initialDoc: pdf_url,
}, document.getElementById('viewer'))
.then(function(instance) {
var docViewer = instance.docViewer;
var annotManager = instance.annotManager;
var Annotations = instance.Annotations;
instance.setHeaderItems(function(header) {
header.push({
type: 'actionButton',
img: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" 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>',
onClick: function() {
onSave();
async function onSave() {
var xfdf = await annotManager.exportAnnotations({ links: false, widgets: false });
var fileData = await docViewer.getDocument().getFileData({});
// var blob = new Blob([fileData], {type: 'application/pdf'});
var data = new FormData();
data.append('xfdf', xfdf);
data.append('file', 'http://africau.edu/images/default/sample.pdf');
data.append('license','');
// Process the file
var response = await fetch('https://api.pdfjs.express/xfdf/merge', {
method: 'post',
body: data
}).then(resp => resp.json());
var { url, key, id } = response;
// Download the file
var mergedFileBlob = await fetch(url, {
headers: {
Authorization: key
}
}).then(resp => resp.blob())
instance.loadDocument(mergedFileBlob);
/* var data_PDF = new FormData();
data_PDF.append('data' , mergedFileBlob);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
$('#cover-spin').hide(0);
$("#ed-alert").css("display", "block");
setTimeout(function() { $("#ed-alert").css("display", "none"); }, 5000);
} else {
$('#cover-spin').show(0);
}
}
xhr.open('POST', upload_url, true);
xhr.send(data_PDF);*/
// Do something with blob...
// save(mergedFileBlob)
}
}
});
});
});
Hi,
Having disableFlattenedAnnotations: true,
will disable any annotations from rendering unless you import the XFDF directly, that is why the annotations aren’t rendering.
Dear Logan,
I have tried small size pdf it is working perfect.When i try 15 MB PDF getting Internal server error.Please check given pdf url
[http://smoinoman.com/pdf/testdraw.pdf](http://Test Pdf)
Thank you!
I will try this document out and see what’s going on. This is a pretty complex document.
Hi @jithinkp, this should be fixed now! (issue was just that the request was timing out)
Thanks,
Logan