PDFJS getTextContent()承诺仍然“待定”

时间:2018-12-05 00:31:26

标签: javascript pdf pdfjs

我正在尝试在pdf页面中获取文本。我的工作如下:

pdfjsLib.getDocument({ url: "x.pdf" }).then(function(pdf_doc) {
    pdf_doc.getPage(1).then(function(page) {//Page 1 exists in x.pdf
        console.log("Here is reached 1",page);
            var tc = page.getTextContent(1).then(function (textContent) {
                console.warn("Here is not reached",textContent);
            }).catch(function(p) {
                console.error("Neither reached, ever");
            });
            console.info("Reached, tc is 'pending':",tc);
    });    
    console.log("Here is reached 3",pdf_doc)
})

如注释所示,在有效页面中的调用getTextContent()返回一个Promise,该Promise将保持待处理状态。

我收到错误消息(在Firefox控制台中):

 Error: Unknown action from worker: PDFManagerReady

我找不到原因,很多人似乎已经在互联网上成功使用了此代码。

0 个答案:

没有答案