【问题标题】:Extjs pdf plugin readerExtjs pdf 插件阅读器
【发布时间】:2016-06-15 20:30:43
【问题描述】:

您好,我正在尝试将https://github.com/mozilla/pdf.js 用于我的 extjs 项目。 我正在使用 sencha 命令来构建项目。

我按照链接https://github.com/mozilla/pdf.js/wiki/Setup-PDF.js-in-a-website中提供的步骤提取了文件

解压 ZIP 文件(将创建一个名为“pdf.js-gh-pages”的目录)。 将以下目录复制到您的网站: pdf.js-gh-pages/build/ pdf.js-gh-pages/web/

在我的代码中,这是我尝试链接/打开 pdf 文件的方式

      if(id == 'GUID-30C74FE7-C729-4BD2-9D1C-6F1D0F360BFF_1_en-US') {
            var pStyle = 'height: 100%; width: 100%; border: none';
            var pContentType = 'pdf';
            <a href="/web/viewer.html?      file=FCCOnline.Globals.getBaseURL()+'/resources/pdf/70150_GUID-210DB618-7184-482E-8A44-3602110B33B6_1_en-US.pdf'">Open yourpdf.pdf with PDF.js</a>  
}

将这些文件添加到 index.html

<link rel="stylesheet" type="text/css" href="resources/web/viewer.css"/>
    <script type="text/javascript" src="resources/build/pdf.js" ></script>
    <script type="text/javascript" src="resources/build/pdf.worker.js" ></script>
    <script type="text/javascript" src="resources/web/compatibility.js"></script>
    <script type="text/javascript" src="resources/web/viewer.js"></script>

我遇到了一个错误一个错误

app.js?_dc=20160615140509:1 未捕获错误:[Ext.getBody] document.body 尚不存在getBody @ app.js?_dc=20160615140509:1init @ app.js?_dc=20160615140509:1(匿名函数)@app.js?_dc=20160615140509:1 pdf.worker.js:42647 提供的值“moz-chunked-arraybuffer”不是 XMLHttpRequestResponseType 类型的有效枚举值。 viewer.js:2236 未捕获类型错误:无法读取未定义(匿名函数)@ viewer.js:2236CSS_UNITS @ viewer.js:2222(匿名函数)@ viewer.js:2224(匿名函数)@ viewer.js 的属性“PDFJS” :9318

【问题讨论】:

  • 我不明白...你是在你的JS代码中间写一个HTML标签吗?

标签: javascript pdf extjs


【解决方案1】:

这就是我试图在 extjs 文件中访问的方式

var main = Ext.create({
    xtype : 'main-frame',
    id : 'mainFrame',
    loader : {      url:FCCOnline.Globals.getBaseURL()+'/resources/pdf/70150_GUID-210DB618-7184-482E-8A44-3602110B33B6_1_en-US.pdf',
        renderer : 'pdf',
        autoLoad : false,
        scripts : true
    }
}); 

在 viewer.js 中我做了这个改变—— viewerContainer: document.getElementById('mainFrame'),

【讨论】:

    猜你喜欢
    • 2018-07-28
    • 1970-01-01
    • 1970-01-01
    • 2011-07-07
    • 2018-04-17
    • 1970-01-01
    • 2011-10-29
    • 2021-06-02
    • 1970-01-01
    相关资源
    最近更新 更多