Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Questions on compiling and using PDF.js

2,095 views
Skip to first unread message

don rhummy

unread,
Jul 17, 2013, 4:55:36 PM7/17/13
to dev-p...@lists.mozilla.org
I'm looking to use PDF.js in an HTML5 web app I'm building. However, it is not clear to me how exactly I should build the pdf.js. The examples I've seen include about 30 javascript files (for example "viewer.html") but do not say how to know which ones I need to include, nor whether I can build them into just one massive JS file (or even how to do that). I apologize but the documentation for this project is really just the "ReadMe" file so I'm a little confused. I have a few questions:

1. Is the PDF.js created by "node make generic" the only file I need to include? Or do I need more files?

2. Can it only open files from a "file:/" url? Or can it handle files within the same web url (e.g. "pdfs/mypdf.pdf")

3. Is there any tutorial code that shows how to the basic functions: e.g. load a PDF, show the page and move from page to page without a lot of other stuff?

The included examples are very complex and loaded with a lot of code in addition to the general functionality of pdf.js and it's making it very difficult to figure out how to even load a PDF.

Thank you for any help you can give!

Don

Brendan Dahl

unread,
Jul 17, 2013, 5:02:20 PM7/17/13
to don rhummy, dev-p...@lists.mozilla.org
1. https://github.com/mozilla/pdf.js#building-pdfjs include pdf.js and the compatibility.js file if you want to support more browsers.

2. You can load any file you can load with a regular XHR request or file input element.

3. https://github.com/mozilla/pdf.js/tree/master/examples/helloworld
> _______________________________________________
> dev-pdf-js mailing list
> dev-p...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-pdf-js

don rhummy

unread,
Jul 17, 2013, 5:08:53 PM7/17/13
to dev-p...@lists.mozilla.org
Thank you, that helps me get started!

The HelloWorld doesn't have
any code on moving through a PDF by pages. Is there a "JavaDoc"
type documentation anywhere for the different functions available?

I appreciate your help!

Don



________________________________
From: Brendan Dahl <bd...@mozilla.com>
To: don rhummy <donr...@yahoo.com>
Cc: "dev-p...@lists.mozilla.org" <dev-p...@lists.mozilla.org>
Sent: Wednesday, July 17, 2013 5:02 PM
Subject: Re: discussions of PDF.js project Questions on compiling and using PDF.js

don rhummy

unread,
Sep 27, 2013, 2:12:47 PM9/27/13
to dev-p...@lists.mozilla.org
I want to run PDF.js within Chrome (a chrome app). When I downloaded PDF.js it says I need to build it using Node (why do I need to install node to build this project?) but I also see the following files:
src/pdf.js
src/worker_loader.js
web/compatibility.js


Are these files OK to use? If I include those three files (all in the subfolder "scripts") will my PDF viewer work?

Or do I need to build it?

If I'm creating my own viewer, do I need anything beyond those three files?

Brendan Dahl

unread,
Sep 27, 2013, 2:23:26 PM9/27/13
to don rhummy, dev-p...@lists.mozilla.org
https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#wiki-gh-pages

and from the readme
In order to bundle all src/ files into two productions scripts and build the generic viewer, issue:

$ node make generic
This will generate pdf.js and pdf.worker.js in the build/generic/build/ directory. Both scripts are needed but only pdf.js needs to be included since pdf.worker.js will be loaded by pdf.js. If you want to support more browsers than Firefox you'll also need to include compatibility.js from build/generic/web/. The PDF.js files are large and should be minified for production.

ja...@hotmail.com

unread,
Mar 4, 2014, 4:55:15 AM3/4/14
to
Really the whole process is a bit pants. Why do they not just provide a pre-built version?

I want jQuery, I go to JQuery and I download it. Done. I don't have to download the source using tool a, build it using tool b, etc....

I just want to download pdf.js, which really shouldn't be that hard.
0 new messages