In Webviewer 6.0.4, I’m trying to optimise a large PDF File through 2 methods but can’t seem to make them work. What am I doing wrong please ?
1 - Linearization method
I use the linearization method on client side as follows (link: https://www.pdftron.com/documentation/web/guides/get-file-data-with-viewer/ ) , but the output doesn’t give me a linearized document.
`
var doc = viewerInstance.docViewer.getDocument();
doc.getPDFDoc().then(function() {
annotManager.exportAnnotations().then(xfdf => {
var options = {
xfdf,
flags: viewerInstance.CoreControls.SaveOptions.LINEARIZED,
downloadType: ‘pdf’,
flatten: true
};
doc.getFileData(options).then(function(docBuf){
var arr = new Uint8Array(docBuf);
var blob = new Blob([arr], { type: ‘application/pdf’ });
const url = URL.createObjectURL(blob);
viewerInstance.loadDocument(url);
});
});
});
`
2 - Optimize viewer method
I try to use the optimize viewer method (link: https://www.pdftron.com/documentation/web/guides/viewer-optimized-pdf?searchTerm=optimize) but can’t make it work. If I store the file on web storage firebase (Azure, Firebase, Amazon …) what should I put in outputPath ?
`
var doc = viewerInstance.docViewer.getDocument();
doc.getPDFDoc().then(function(pdfDoc) {
var options = {
thumbnailSize : 1024,
thumbnailRenderingThreshold: 40
}
pdfDoc.saveViewerOptimized(’/output/path’, options);
});
}
`
Thanks in advance for your help.