Pdf.js: ReferenceError: pdfjsViewer 未定义

创建于 2019-02-11  ·  3评论  ·  资料来源: mozilla/pdf.js

总之,我正在尝试 Acroform 示例。 我正在尝试查看托管在我的服务器上的 pdf,但它给了我错误:未捕获(承诺)ReferenceError:pdfjsViewer 未定义

在此处附加(推荐)或链接到 PDF 文件:该文件托管在我的服务器上。

配置:

  • Web 浏览器及其版本:Google Chrome 版本 72.0.3626.96(官方版本)(64 位)
  • 操作系统及其版本:Windows 10
  • PDF.js 版本:v2.1.245
  • 是否为浏览器扩展:否

我在 var pdfPageView = new pdfjsViewer.PDFPageView({

代码如下:

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));
        }
    });

1-other

所有3条评论

我在 var pdfPageView = new pdfjsViewer.PDFPageView({

WFM,当按照https://github.com/mozilla/pdf.js/tree/master/examples/acroforms#getting -started 上的说明进行操作时。

这个例子应该有效。 确保不要忘记dist-install步骤。

我的错。 而不是使用位于 pdfjs-dist 的查看器
pdf.js\node_modules\pdfjs-dist\web\pdf_viewer.js ,我在pdf.js\web\viewer.js使用查看器。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

aaronshaf picture aaronshaf  ·  3评论

anggikolo11 picture anggikolo11  ·  3评论

BrennanDuffey picture BrennanDuffey  ·  3评论

liuzhen2008 picture liuzhen2008  ·  4评论

sujit-baniya picture sujit-baniya  ·  3评论