Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Loading a PDF document from flipbook sample

111 views
Skip to first unread message

Matt Parizeau

unread,
Jan 9, 2017, 5:58:22 PM1/9/17
to PDFTron WebViewer
Q:

The flipbook sample included with WebViewer loads a XOD document but is it possible to load a PDF document directly?

A:

Yes, you just need to replace the function at the bottom of flipbook.js with the following:
$(function() {
   
var readerControl = new ReaderControl();
   
var queryParams = window.ControlUtils.getQueryStringMap();

   
var docPath = queryParams.getString('d');
   
if (docPath === null) {
       
return;
   
}

   
var pdfPartRetriever = new CoreControls.PartRetrievers.ExternalPdfPartRetriever(docPath, {});
   
CoreControls.getDefaultPdfBackendType().then(function(pdfType) {
       
var workerHandlers = {};

       
var workerTransportPromise = CoreControls.initPDFWorkerTransports(pdfType, workerHandlers);

       
var options = {
            type
: 'pdf',
            pdfBackendType
: pdfType,
            workerHandlers
: workerHandlers,
            workerTransportPromise
: workerTransportPromise
       
};

        readerControl
.docViewer.loadAsync(pdfPartRetriever, options);
   
});
});

Reply all
Reply to author
Forward
0 new messages