Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF.js getDocument promise does not come back #380

Closed
Waize opened this issue Apr 2, 2019 · 4 comments
Closed

PDF.js getDocument promise does not come back #380

Waize opened this issue Apr 2, 2019 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@Waize
Copy link

Waize commented Apr 2, 2019

Before you start - checklist

  • [/] I have read documentation in README
  • [/] I have checked sample and test suites to see real life basic implementation
  • [/] I have checked if this question is not already asked

What are you trying to achieve? Please describe.

I've upgraded from Version 3.0.5 to 4.0.5. After the update my PDF-Files will not be displayed anymore and it keeps "loading".

Describe solutions you've tried

I display my PDF-File as base64-data but tried plain bytes too. Using the provided notification hooks gives me the feedback, that sourcedata is loaded correctly.
Debugging into your code leads me to Document.js and this code:

  cancellable = (0, _utils.makeCancellable)(loadingTask.promise);
  _this.runningTask = cancellable;
  _context.next = 23; // until here is everything fine
  return cancellable.promise; // this promise is never resolved 

Additional information

I use your lib straight forward:

import { Document, Page } from "react-pdf/dist/entry.webpack";
 <Document
          file={ isDataBase64 ? `data:application/pdf;base64,${file}` : file }
          loading="Das PDF wird geladen..."
          onLoadSuccess={ ::this.onDocumentLoadSuccess } // show additional buttons for zoom
          className="pdfDocument"
          renderMode="svg"
        >
            <Page
              key={ `page_${1}` }
              pageNumber={ 1 }
              className="pdfPage"
              renderMode="svg"
              scale={ pageScale } />
        </Document>

I've attached a sample PDF for you. Copy+paste it into your browser will work. Using it at the parameter for <Document file={<pdfdata here>}> does not work.
samplePDF_base64.txt

Environment

  • Browser (if applicable) [e.g. Chrome 57, Firefox 59]: Chrome and FF latest
  • React-PDF version [e.g. 3.0.4]: 4.0.5
  • React version [e.g. 16.3.0]: 16.3.2
  • Webpack version (if applicable) [e.g. 4.16.2]: 3.8.1
@wojtekmaj
Copy link
Owner

It definitely worked for me both pasting it in browser's address field and passing as an URL to file prop in React-PDF! Maybe you're "base64-ing" it twice?

obraz

@wojtekmaj wojtekmaj added the question Further information is requested label Apr 2, 2019
@wojtekmaj wojtekmaj self-assigned this Apr 2, 2019
@Waize
Copy link
Author

Waize commented Apr 2, 2019

No, this pdf-data is equal to the string, I pass into Document.
Is there any way to find out what PDFjs is doing?

@Waize
Copy link
Author

Waize commented Apr 2, 2019

Damn, this caching.

Deleting all the site caches in Chrome made it work.

Thanks for your fast answer!

@Waize Waize closed this as completed Apr 2, 2019
@paulzala
Copy link

In case it's helpful to anyone else, I also experienced the same never-resolving promise behaviour when I'd accidentally set the url for the worker (pdfjsLib.GlobalWorkerOptions.workerSrc = "....") to point to the main pdf.js file instead of the pdf.worker.js file by mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants