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
How to get pdf.js working? #3508
Comments
This is a place to report bugs. It is not a support forum. |
Thanks benbro, Would you please suggest a website that could offer such support? |
All the info you are looking for is on the README on the front page: |
@AliND The examples provided by @benbro should do the trick. It's indeed best to download the entire zip or tp clone the repository. I got it working by simply cloning the repository and running it on a local XAMPP instance. Do not forget that the actual viewer is in the Are you trying to get it working on a web server or on a local XAMPP/WAMP instance? Please post any additional information (exact error messages/warnings from the console and OS/browser) if you keep on getting errors. If you're uploading it to a web server, a link to your viewer can also help track down any problems. We'll be happy to help if you really can't seem to figure it out yourself. :) |
@timvandermeij First I thank you for your kind reply. I also thank @benbro very much, but the links didn't help me solve the problem. I noticed that many people are(were) having the same problem. Some had it unsolved, while those who had it solved didn't show the steps! I believe that writing such a very small guide on how to get it working for beginners would be very useful. @timvandermeij , I can't install XAMPP or any other server agent for some reasons. I have just created a free account, which you can access with the following ftp user details: I tried three different approaches, and I got three different pdf warnings: 1- I downloaded everything with WinHTTrack, then uploaded them and I get this error: 2- I get this error (no warning message), but the page doesn't display 3- If I upload the whole zipped folder (all files), I arrive at this error: I really appreciate your help. |
Looking at http://pdfjs.eu.pn/pdf.js/build/pdf.js, there is "GET" replaced by "GET.html" at your server (probably mirroring program), e.g.:
A the http://mozilla.github.io/pdf.js/build/pdf.js it is without ".html". Closing the issue as invalid. |
use git to pull the gh-pages brach with the production code: |
Many thanks @yurydelendik - I really appreciate your input. However, I am a novice with php and javascript. I have tried your advise (GET), and it is indeed useful. Now, the loader shows, but not the document. Actually, when I first uploaded the web & src folders, I did so, based on your hint in the following thread: I don't know Yury, but seems many beginners, face the same issue. I mean, I strongly believe that there is an easy way just like in the following example (mentioned before), where you just upload the folders to get it working, it will be very helpful for me, as well as many others. I don't want to appear like putting my noise in other people business, but providing a very short tutorial of such for beginners, in the main Pdf.js page, would be very useful. Regardless whether my problem is solved or not, I thank you all for your kind assistance. |
For beginners there lots of things can go wrong. First thing I recommend to the beginners is to follow the README file, FAQs and advices provided in the issues. Was you able to setup node.js, clone project using git and build it? Did you try following my advice to use the git command above? Deployment the pdf.js on the custom platform is out of scope of this project, however we will be glad to accept the detailed step-by-step instructions from the contributors/experts for particular platform (in form of wiki page). If you think we are missing something and you know how to solve the common case, please create a wiki page. |
@AliND It seems you are missing some files. The viewer on http://pdfjs.eu.pn/pdf.js/web/viewer.html seems fine to me, but the console claims that: "NetworkError: 404 Not Found - http://pdfjs.eu.pn/pdf.js/build/compressed.tracemonkey-pldi-09.pdf" i.e. the PDF file does not exist at that location. Place it there, and it should be fine. The second link is not working because you are missing the following files: "NetworkError: 404 Not Found - http://pdfjs.eu.pn/pdf2.js/external/webL10n/l10n.js" l10n.js "NetworkError: 404 Not Found - http://pdfjs.eu.pn/pdf2.js/external/jpgjs/jpg.js" jpg.js "NetworkError: 404 Not Found - http://pdfjs.eu.pn/pdf2.js/external/webL10n/l10n.js" l10n.js "NetworkError: 404 Not Found - http://pdfjs.eu.pn/pdf2.js/external/jpgjs/jpg.js" Please check and make sure that the mentioned files can be found at that path. For what I can tell, that should do it. Tip: use the Firefox console ( |
@AliND http://pdfjs.eu.pn/pdf.js/web/viewer.html is now partially working because I added the PDF file to the build directory. The fact that this is needed might indicate something fishy happened during the build process. I'll look into it a bit more for you and hopefully give you better feedback. |
@AliND Here you go: http://pdfjs.eu.pn/pdf3.js/web/viewer.html What I've done:
Nothing special, so strange that it's working for me. The second link is definitely missing some folders, so that's why that didn't work. I have no clue as to why the first link is not working the way it should, but I'd guess the build of PDF.js wasn't entirely successfull. Although this will work just nicely, I agree that it's better to build it instead of just unzipping it. I hope you can work with this for now. In the meantime, I'll try to build PDF.js myself and test it on your server. If I can get that working, I'll also post the steps and hopefully all problems will be fixed then :-) |
@AliND The built version is also working for me, though I admit I had to figure out a bit how it worked. I've never built PDF.js before, so I started with https://github.com/mozilla/pdf.js/wiki/Setup-PDF.js-in-a-website-%28Debian-Ubuntu%29#wiki-Setup_testing_environnement, but that didn't quite give me a good result. I did the following to get it working on your server (link here: http://pdfjs.eu.pn/pdf.js-build/web/viewer.html):
I hope your problems are solved by following the steps I've provided here and in my previous comment. Good luck (and sorry for the wall of text!). :-) @yurydelendik I also find the manual at https://github.com/mozilla/pdf.js/wiki/Setup-PDF.js-in-a-website-%28Debian-Ubuntu%29#wiki-Setup_testing_environnement slightly confusing. In the section |
@timvandermeij, so you followed instruction for ubuntu to setup it on windows? yeah, you will need a special environment for windows to do that (not easy to setup for beginner e.g. https://github.com/mozilla/pdf.js/wiki/Setting-up-pdf.js-Development-Environment-for-Windows). Yeah, the wiki is confusing, but an interest in "testing environment" already indicate are not a beginner. But yeah if you find it confusing and you found the right way, please make a change (but in case of windows it deserves another wiki page) Added entry to the FAQs: https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#wiki-gh-pages |
@yurydelendik Thanks. I practically did the same on Windows as I would do on Arch Linux for example, but I'll take a shot at extending the wiki. :) |
@yurydelendik I've extended the Linux instructions page on https://github.com/mozilla/pdf.js/wiki/Setup-PDF.js-in-a-website-%28Linux%29 to fix the issues I experienced with it, and also to correct some textual mistakes. That page seems fine to me now. Later this day, I'll make the same type of page, but then focussed on Windows (which is currently a to-do item). Hopefully adding more instructions will cause less confusion amongst users. :) Edit: here is the Windows version: https://github.com/mozilla/pdf.js/wiki/Setup-PDF.js-in-a-website-%28Windows%29 I hope you're happy with the changes made to the Linux and Windows pages of the wiki. I think they are easier to understand now, and now we also have documentation for Windows :) |
@timvandermeij thank you for doing that. |
@timvandermeij : What you did is outstanding; thank you for every second you spent there. I am 100% sure that this will be useful for many others as well. Checking is in progress, I shall come back with the outcome very soon. @yurydelendik : Many thanks for the input, seems that Tim has done it all! Thanks again & all best// |
@AliND, @yurydelendik Very happy to help! I would indeed like to hear the outcome. :-) |
@timvandermeij The only needed folders are the web! and the build (with only the pdf.js & the pdf file to be built). Additionally, the locale folder (with locale.properties inside it, if we copy the file from github to local server) should be included in the web folder. For this pretty easy, straight-forward method, credit goes to you @timvandermeij for guidance on where to put the pdf file (inside the build folder), and to @yurydelendik for figuring the GET.html problem. http://pdfjs.eu.pn/pdffinal/web/viewer.html But still there is one problem, it views perfectly in Firefox, Chrome, and Opera. For Explorer and Opera, however, there are two errors: I mean, I feel like it is strange because the compatibility.js is there, and I wonder what could cause this behavior for these browsers. Anyways, I have also uploaded all the other files and folders but didn't have luck!. @timvandermeij: If I use your method, and upload the whole folder like I did before, I get the following error in the following link. Kindly note that, no matter whether I extract and upload or upload and extract -> same problem. Besides, pdf.js-master.zip & mozilla-pdf.js-v0.5.5-1283-gc682c25.zip are the same files, so I wonder why two at a time. I just don't understand why! I have even downloaded the folder pdf3.js you uploaded, reuploaded it again! and still, it doesn't work! I mean, what I am really concerned about is the reason for which it is not working with the two other browsers! Any ideas? |
@timvandermeij I have installed GIT and run into different sort of problems. Thus, I would rather focus on first solution. I wonder if you can provide me with answers to the two following questions: Thanks again - I appreciate your help as well as @yurydelendik 's help. All Best, |
I got it working, Thanks Tim - I used Safari element inspector this time and for some reasons, it is directing toward web/sample.pdf instead of build/sample.pdf. Same goes for Internet Explorer! Kindly note the internal links in the pdf file doesn't work in IE but this is not a problem. Without any doubts, the build method is the correct one although one can create separate viewer.js for each pdf file. Now if you go to http://pdfjs.eu.pn/pdffinal/web/viewer.html , it works in all the 5-mentioned browsers. (note: sometimes, the browsers can't find some files on this free server, but on the paid server - it works without any problems). For future users, an easy way is: @timvandermeij I just don't understand why it doesn't work when I upload the master folder!, because in your case, it worked flawlessly! Anyways, many thanks for your kind help and support, and I would say it again, as per @yurydelendik & @timvandermeij instructions, "the correct method" is the build one; but since I am finance researcher - I can't really dig deep into the matter for time issues. Thanks again and all - all best// |
@AliND Nice that you got it working! Indeed, the build way is the best way to go, but the other method should also work fine. I did nothing else but download the ZIP file and extract it on the server. No other modifications. It worked flawlessly, so it's strange that it didn't work for you. However, the most important thing is that you got it working in all browsers for your purpose. Also thanks for placing your steps here. It might help future users that still experience trouble with the updated wiki pages. The way described on the wiki pages is definitely the way to go and is a working method, but if for some reason it doesn't work for someone, your steps might serve as help. I do not know how a wrong link to a PDF file can only break Safari and IE, and not the other browsers. Perhaps there is a problem with that free account, I cannot tell. Glad that you got it working and all the best indeed! :-) |
@AliND Additionally, note that adapting |
@timvandermeij Many thanks again :) Actually, your method works perfectly on the free server; I just tried it but seems that I have the problem with the paid server this time! I have just opened a support ticket so they can look up into the issue. So for future users also, and aside from the build method, what @timvandermeij did works perfectly and it is much easier than the previously mentioned method. For reference: Thanks again Tim :) |
Wow, the file method is indeed very helpful! :) @timvandermeij you have provided a one-stop complete solution :) Thanks again & again and all best// |
Hi |
@xiaotun The PDF file seems to be corrupt. Please open a new issue and provide more details such as OS name/version, PDF.js version and browser name/version. |
I'm getting Warning: TT: undefined function: 32 in the console. Could not load source 'VM_Unknown': Could not retrieve content.. VM_Unknown:1 The pdf is rendered in the Browser ok, but the form inputs are not there! I've tried to follow this tutorial: |
Dear All,
I knew about pdf.js just this morning, and it is unbelievably good; probably the future of Pdf.
I wanted to clone the demo, so that I just change the source page in the viewer.js.
First, I downloaded the images and elements manually - didn't get it working. Then, I downloaded the zip, and played a lot with the web & src folders - but got no where, as I was getting different kinds of errors everytime I upload them.
The final solution was to download all the items related to the demo page including locale.properties using WinHTTrack , and now, I am just getting the following error: "InvalidPDFException".
There is one guy, who developed a simple demo - I uploaded it to my server and it works like a charm. The only problem is that it is an old version with no pre-loader, and no design at all like the new one!
http://www.worldwidewhat.net/2011/08/render-pdf-files-with-html5/
Any help is really appreciated.
The text was updated successfully, but these errors were encountered: