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.worker.js returns Error 404 #387

Closed
b-asaf opened this issue Apr 22, 2019 · 1 comment
Closed

pdf.worker.js returns Error 404 #387

b-asaf opened this issue Apr 22, 2019 · 1 comment
Labels
duplicate This issue or pull request already exists question Further information is requested

Comments

@b-asaf
Copy link

b-asaf commented Apr 22, 2019

Hi @wojtekmaj, first I would like to say that this package is great and easy to use.

now, the issue I encounter - When I tried to increase the performance as advised in the readMe file I've encountered an issue.

My code that works is:

import { Document, Page } from 'react-pdf';
....
..extra logic
...
   handleDocumentLoadSuccess = ({ numPages }) => {
        console.log(`document with ${numPages} pages was loaded successfully`);
    }

    handleDocLoadError = (error) => {
        console.error(`failed to load document: ${error.message}`);
    }

    handleLoadProgress = ({ loaded, total }) => {
        console.log(`Loading a document ${(loaded / total) * 100}%`);
    }

    handleLoadSuccess = (page) => {
        console.log(`Now displaying a page number: ${page.pageNumber}`);
    }

    handlePageLoadError = (error) => {
        console.error(`failed to load page: ${error.message}`);
    }

    handleRenderError = (error) => {
        console.error(`failed to render page: ${error.message}`);
    }

    renderReport = () => {
        const report = reports[this.props.guid];

        return (
            <Document
                className="pdf_document"
                file={report}
                onLoadSuccess={this.handleDocumentLoadSuccess}
                onLoadError={this.handleDocLoadError}
            >
                <Page
                    pageNumber={1}
                    width={windowWidth}
                    className="pdf_page"
                    scale={0.5}
                    onLoadProgress={this.handleLoadProgress}
                    onLoadSuccess={this.handleLoadSuccess}
                    onLoadError={this.handlePageLoadError}
                    onRenderError={this.handleRenderError}
                />
            </Document>
        );
    }

This works great and I can see in the console all the relevant logs I added without an error.
(I can see an error in the console - pdf.js:11096 GET http://localhost:8090/pdf.worker.js 404 (Not Found), but the PDF file loaded and visible)

When I change the 1st line of code to:
import { Document, Page } from 'react-pdf/dist/entry.webpack';

  • In the console:
    -- No custom error from the added methods
    -- No error regarding pdf.worker.js like mentioned above.

  • On the Screen:
    -- Can't see nothing on the screen

  • In DevTools the html element is:

<div class="react-pdf__Document pdf_document">
  <div class="react-pdf__message react-pdf__message--loading">Loading PDF…
  </div>
</div>

Is it stuck on loading?
if yes, why?

@wojtekmaj
Copy link
Owner

Hi,
please see #97 and other issues mentioned in this thread. This topic has already been discussed. Happy coding!

@wojtekmaj wojtekmaj added duplicate This issue or pull request already exists question Further information is requested labels Apr 24, 2019
@wojtekmaj wojtekmaj changed the title webpack issues pdf.worker.js returns Error 404 Apr 24, 2019
alexandernanberg pushed a commit to alexandernanberg/react-pdf that referenced this issue Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants