Hi guys, we love PDFJS here. It has been working great for awhile, but we're upgrading all our js libraries and I just upgraded to the newest version yesterday.
Now I'm stuck.
I'm getting an error "PDFJS.getDocument is not a function". I've tried setting the worker path and disabling the worker as suggested in other issues and neither helps. I'd rather not disable the worker if i don't have to.
here is the failing code.
function load() {
PDFJS.disableWorker = true;
// Load PDFs one after another
PDFJS.getDocument(urls[loadedCount]).then(function ( pdfDoc_ ) {
pdfDocs = [];
pdfDocs.push( pdfDoc_);
totalPageCount = getTotalPageCount();
form_item_input_div.append( $('<div id="page_container_'+ loadedCount +'"></div>').hide() );
renderPage( 1 );
}).catch( function (resp) {
form_item_input_div.html($('<span type="text" class="t-text"/>').text( $.i18n._('ERROR: Unable to preview document...') ));
} );
}
It's probably worth mentioning that the documentation should have a section covering how to use pdfjs with require as digging through issues that are years old is not super helpful.
Please provide complete example.
Where can i find an example of the latest code being used with require?
Where can i find an example of the latest code being used with require?
I don't understand this question. require() is not a native JavaScript API method and shall be used in some context (with webpack or node.js).
Examples can be found at https://github.com/mozilla/pdf.js/tree/master/examples . You might need to check webpack or node examples.
Closing as answered.
thanks anyway....
It has been working great for awhile, but we're upgrading all our js libraries and I just upgraded to the newest version yesterday.
Did you by any chance use the PDF.js source files, e.g. the ones in https://github.com/mozilla/pdf.js/tree/master/src, as-is previously?
If so, then please note that while that may have "worked" with earlier versions of PDF.js, it was never a supported configuration. For all non-development usage of PDF.js, the source files need to be built first; please refer to e.g. https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#gh-pages or https://github.com/mozilla/pdf.js#building-pdfjs for more information about downloading (or creating) built versions of PDF.js that's meant for production use.