访问“自动allocatechunksize”的错误在PDFJS中

发布于 2025-01-23 16:06:21 字数 1954 浏览 1 评论 0原文

Firefox 99更新后,我有一个新问题。 我有一个扩展程序,可以使用PDFJS(版本 PDFJS-2.13.216 )读取PDF。它总是有效的,在上次更新之后,它开始给出:错误:拒绝访问属性的权限“ autoallocatechunksize” 相同的扩展和微小的变化通常在镀铬中起作用。 以下是代码:

function getAllTextPDF(urlPDF) {
    return new Promise(function (resolve , reject ) {
        var pdfjsLib = this['pdfjs-dist/build/pdf'];  //this because of firefox
        pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';

        var loadingTask = pdfjsLib.getDocument(urlPDF);
        
        //** from that line it no longer enters and generates the mentioned error **
        loadingTask.promise.then(function(pdf) {
            var numPages = pdf._pdfInfo.numPages;
            var textoFinal = '';
            var pagesPromises = [];
          
            for (var i = 0; i < numPages; i++) {                
                (function (pageNumber) {
                    pagesPromises.push(getPageText(pageNumber, pdf));
                })(i + 1);
            }
                            
            Promise.all(pagesPromises).then(function (pagesText) {

                for (var i = 0; i < pagesText.length; i++) {
                    textoFinal += pagesText[i];
                }
                
                if(textoFinal.length > 0){
                    resolve({text: textoFinal});
                    
                    loadingTask.destroy();
                    delete pdfjsLib;
                    delete loadingTask;
                }                   
            });
        
        }, function (reason) {
            // PDF loading error
            reject({reason});
            return 0;
        });
        
    });          
}

要读取的文件示例URL(正常工作):

blob:https://dominio.com/4db038e1-ae8d-4a15-a78f-0d9d0a182c7c

该方法的想法很简单,浏览PDF文件并返回所有文本。但是,如前所述,该错误已生成。没有在32bit Firefox版本中产生错误的细节,我相信它始于Firefox 99的最后一次更新。

感谢您的帮助。

i have a new problem after firefox 99 update.
I have an extension that reads pdfs using PDFJS (version pdfjs-2.13.216). It always worked and after the last update it started to give: Error: Permission denied to access property "autoAllocateChunkSize"
The same extension, with tiny changes, works in chrome normally.
Below is the code:

function getAllTextPDF(urlPDF) {
    return new Promise(function (resolve , reject ) {
        var pdfjsLib = this['pdfjs-dist/build/pdf'];  //this because of firefox
        pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';

        var loadingTask = pdfjsLib.getDocument(urlPDF);
        
        //** from that line it no longer enters and generates the mentioned error **
        loadingTask.promise.then(function(pdf) {
            var numPages = pdf._pdfInfo.numPages;
            var textoFinal = '';
            var pagesPromises = [];
          
            for (var i = 0; i < numPages; i++) {                
                (function (pageNumber) {
                    pagesPromises.push(getPageText(pageNumber, pdf));
                })(i + 1);
            }
                            
            Promise.all(pagesPromises).then(function (pagesText) {

                for (var i = 0; i < pagesText.length; i++) {
                    textoFinal += pagesText[i];
                }
                
                if(textoFinal.length > 0){
                    resolve({text: textoFinal});
                    
                    loadingTask.destroy();
                    delete pdfjsLib;
                    delete loadingTask;
                }                   
            });
        
        }, function (reason) {
            // PDF loading error
            reject({reason});
            return 0;
        });
        
    });          
}

example URL of file to read (worked normally):

blob:https://dominio.com/4db038e1-ae8d-4a15-a78f-0d9d0a182c7c

The idea of ​​the method is simple, go through the pdf file and return all the text. However now as mentioned the error is generated. Detail that did not generate the error in version 32bit firefox, I believe it started in the last update of firefox 99.

I appreciate your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文