0
votes

Hi I am trying to use https://github.com/mozilla/pdf.js for my extjs project. I am using sencha command to build the project.

I extracted the filesas steps provided in the link https://github.com/mozilla/pdf.js/wiki/Setup-PDF.js-in-a-website

Extract the ZIP file (a directory called "pdf.js-gh-pages" will be created). Copy the following directories to your website: pdf.js-gh-pages/build/ pdf.js-gh-pages/web/

In my code this how i am trying to link/open the pdf files

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

Added these files to 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>

I am hitting an error an error

app.js?_dc=20160615140509:1 Uncaught Error: [Ext.getBody] document.body does not yet existgetBody @ app.js?_dc=20160615140509:1init @ app.js?_dc=20160615140509:1(anonymous function) @ app.js?_dc=20160615140509:1 pdf.worker.js:42647 The provided value 'moz-chunked-arraybuffer' is not a valid enum value of type XMLHttpRequestResponseType. viewer.js:2236 Uncaught TypeError: Cannot read property 'PDFJS' of undefined(anonymous function) @ viewer.js:2236CSS_UNITS @ viewer.js:2222(anonymous function) @ viewer.js:2224(anonymous function) @ viewer.js:9318

1
I don't understand it... are you writting an HTML tag in the middle of your JS code? - SJuan76

1 Answers

0
votes

This is how m trying to access in extjs file

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

and in viewer.js i made this change- viewerContainer: document.getElementById('mainFrame'),