In summary, I'm trying the Acroform example. I'm trying to view a pdf hosted on my server but it is giving me the error: Uncaught (in promise) ReferenceError: pdfjsViewer is not defined
Attach (recommended) or Link to PDF file here: The file is hosted on my server.
Configuration:
I'm getting the error at var pdfPageView = new pdfjsViewer.PDFPageView({
The code is as below:
pdfjsLib.GlobalWorkerOptions.workerSrc = "/js/Lib/pdf.worker.js";
var DEFAULT_SCALE = 1.0;
var container = document.getElementById('viewer_container');
var loadingTask = pdfjsLib.getDocument(pathStringer);
loadingTask.promise.then(function (doc) {
// Use a promise to fetch and render the next page.
var promise = Promise.resolve();
for (var i = 1; i <= doc.numPages; i++) {
promise = promise.then(function (pageNum) {
return doc.getPage(pageNum).then(function (pdfPage) {
// Create the page view.
var pdfPageView = new pdfjsViewer.PDFPageView({
container: container,
id: pageNum,
scale: DEFAULT_SCALE,
defaultViewport: pdfPage.getViewport({ scale: DEFAULT_SCALE, }),
annotationLayerFactory:
new pdfjsViewer.DefaultAnnotationLayerFactory(),
renderInteractiveForms: true,
});
// Associate the actual page with the view and draw it.
pdfPageView.setPdfPage(pdfPage);
return pdfPageView.draw();
});
}.bind(null, i));
}
});
I'm getting the error at var pdfPageView = new pdfjsViewer.PDFPageView({
WFM, when following the instructions at https://github.com/mozilla/pdf.js/tree/master/examples/acroforms#getting-started.
The example should work. Make sure not for forget the dist-install
step.
My bad. Instead of using the viewer from pdfjs-dist which is located at
pdf.js\node_modules\pdfjs-dist\web\pdf_viewer.js
, I was using viewer at pdf.js\web\viewer.js
.