新しいBoxサポートサイトへようこそ。 変更点の詳細はこちらをご確認ください .

PDFJS is not defined

回答済み
新規投稿

コメント

9件のコメント

  • tonyjin

    Hello a1626!

     

    Can you please share some more about your project? What are you using to load Preview's CSS and JS? Are you using any frontend frameworks?

    Also, does this example work with your token and file ID? https://codepen.io/box-platform/pen/rmZdjm (please comment out the collection option).

     

    Thanks,

    Tony

    0
    コメントアクション パーマリンク
  • a1626

    Hi Tonyjin

     

    My project is an angularjs project.

    I've updated the pen with my access token and file id. https://codepen.io/a1626/pen/rYRgoV

    It seems to be working fine in the pen.

     

    Update

    It works if i load all the files from cdn directly ie also import

    Click to expand
    box-preview.js
    pdf.min.js
    pdf_viewer.min.js
    pdf_viewer.min.css
    pdf.worker.min.js
    exif.min.js

    Not sure if leaving one or two imports will do the trick or not.

     

    Only including pdf.min.js throws new error cannot read property 'prototype' of undefined.

     

    0
    コメントアクション パーマリンク
  • tonyjin

    Thanks for the report. Are you using RequireJS? We've seen similar issues in the past, there seems to be some sort of issue with how we load some of our dependencies and how it interacts with other JS loaders.

    0
    コメントアクション パーマリンク
  • a1626

    Yes, we are using requirejs. So, is there any other way to fix this issue other than importing more than required files. Anyways, we would prefer not to load it via CDN.

     

    0
    コメントアクション パーマリンク
  • tonyjin

    I'd suggest continuing to use your workaround for now, but I definitely agree this isn't optimal. We'll take a closer look and fix this.

    0
    コメントアクション パーマリンク
  • schalkkruger

    Hi tonijin,

     

    Is there any progress or update regarding this fix, we have a similar issue using requirejs in v1.25. This could be a critical deal breaker for us.

     

    Thanks.

    0
    コメントアクション パーマリンク
  • jpress

    Hi , Our fix has been merged, and is scheduled for the next release. https://github.com/box/box-content-preview/pull/561

    0
    コメントアクション パーマリンク
  • schalkkruger

    That is absolute wonderful news, thanks 

    0
    コメントアクション パーマリンク
  • logicbomber

    This error still occurs.. for us it was when the preview was loading and a user was scrolling over the container.

     

    I'm guessing there is a scroll event listener (or other mouse event listener) that's firing something before PDFJS is ready.  

     

    We are using the libraries from the CDN since we are using Angular for our framework.

    (would be wonderful if there was an Angular library in the works!)

    We're rendering many instances of the previewer in a list view.

    The error is usually triggered when the user scrolls through the list prior to the previewer fully loading.

     

    I worked around it by checking for an error and retrying the load. 

    Here's the code in case anyone else can find it useful.

     

     

    image.png

     

    image.png

    0
    コメントアクション パーマリンク

サインインしてコメントを残してください。