-
-
Notifications
You must be signed in to change notification settings - Fork 848
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
Not working using browserify, but I don't know if it's still the cause #33
Comments
Hey, Consider making something like this using gulp like they do in their official example? |
Sorry, I gave you the repo URL using SSH, that needs my SSH key. Use:
Yes, after copying
It does not. Those errors are shown, and the PDF fails to load (it hangs on "Loading PDF..." forever).
Can I ask you if you think it's relevant, considering I'm just rendering a single page when my app loads? If not, I prefer having a smaller bundle. Giving I'll be able to make React-PDF work without it... |
Replying to the comment you wrote on the wrong issue: 😄
Using nnarhinen/react-pdf#43 the 404 errors go away, but I still get the |
Hah, thank you for being so observant! :D Answering your question about relevancy, it does not really work this way, that it loads several hundred kb and the only advantage is a separate thread. PDF.js still needs everything that is inside pdf.worker.js, whether or not it is treated as a worker. Disabling worker just causes it to load in one thread, which gives you no benefits whatsoever. Long story short - worker has to be there. I just released v2.0.0-beta and I've made sure to make instructions clear about this. Let me know if I could help you with anything else! |
By the way, to upgrade your test project to 2.0.0:
"react-pdf": "^2.0.0-beta"
"build": "npm run copy-worker && npm run build-browserify",
"build-browserify": "browserify index.jsx -t [ babelify --presets [ es2015 react stage-2 ] ] --outfile build.js",
"copy-worker": "copy node_modules\\pdfjs-dist\\build\\pdf.worker.js pdf.worker.js",
import React, { Component } from 'react';
import { render } from 'react-dom';
import { Document, Page } from 'react-pdf';
render(<Document file="sample.pdf"><Page pageIndex={2} /></Document>, document.getElementById('app')); Enjoy :) |
I tried 1.8.3 with Browserify, and I still have problems in running my app. Instead of trying to build the provided sample as I did discussing nnarhinen/react-pdf#39, this time I tried writing a minimal app from scratch. The issue looks different from before.
PDF loading fails, and in the console I see:
The text was updated successfully, but these errors were encountered: