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

can pdf.js be run standalone and if so how?

2,466 views
Skip to first unread message

mike

unread,
Aug 22, 2013, 10:58:59 AM8/22/13
to dev-p...@lists.mozilla.org
Thanks for any information.

Mike

Tim van der Meij

unread,
Aug 23, 2013, 4:13:02 AM8/23/13
to
Op donderdag 22 augustus 2013 16:58:59 UTC+2 schreef mike:
> Thanks for any information.
>
>
>
> Mike

Yes, you can build PDF.js such that you will end up with almost a single .js file that you can use in your standalone applications. For more information, please refer to https://github.com/mozilla/pdf.js/wiki/Setup-PDF.js-in-a-website for build instructions.

mike

unread,
Aug 23, 2013, 6:12:27 AM8/23/13
to dev-p...@lists.mozilla.org
> _______________________________________________
> dev-pdf-js mailing list
> dev-p...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-pdf-js
>
>
Hi Tim

I already have the server built and running and the test works and I've
already done what the link above says and
~/pdfjs/build/generic/build/pdf.js and
~/pdfjs/build/generic/build/pdf.worker.js have been created but I don't
know how to use the results standalone. I've tried 'js
build/generic/build/pdf.js ~/pdfjs/examples/helloworld/helloworld.pdf'
in thepdfjs directory for example but nothing happens (although there
are no error messages or anything). Can you please tell me what else I
need to do to use pdf.js standalone. (I just barely know anything about
javascript I have to confess.)

Best
Mike

Tim van der Meij

unread,
Aug 23, 2013, 3:09:20 PM8/23/13
to
Op vrijdag 23 augustus 2013 12:12:27 UTC+2 schreef mike:
Hi Mike,

I do not know exactly what you mean with using it 'standalone', but from your description I assume you want to open a PDF file dynamically instead of hardcoding a file path. In that case, you can use the hash tag in the URL of your PDF.js location. See https://github.com/mozilla/pdf.js/wiki/Viewer-options for an example.

Kind regards,
Tim

Tim van der Meij

unread,
Aug 23, 2013, 3:10:51 PM8/23/13
to
Op vrijdag 23 augustus 2013 21:09:20 UTC+2 schreef Tim van der Meij:
Sorry, I meant the question mark in the URL. The wiki link I posted has a correct example.

mike

unread,
Aug 23, 2013, 5:07:54 PM8/23/13
to Tim van der Meij, dev-p...@lists.mozilla.org
What I mean by standalone is without a browser as an independent
application. From what I've read since I posted I believe this is
impossible. But there are references in the git documentation pages
about including pdf.js "in your application". In particular I'd just
like to run it from the command line. Obviously from the documentation
pdf.js (I believe) pdf.js needs to be part of an application. I just
want to know what the minimal thing I have to do is to get it to display
PDF files without using a browser, in other words, to act like Adobe
Reader or xpdf or ghostscript or evince. Hope this is clearer.

Best
Mike

Tim van der Meij

unread,
Aug 24, 2013, 7:02:50 AM8/24/13
to
Op vrijdag 23 augustus 2013 23:07:54 UTC+2 schreef mike:
Hm, not sure. I'm pretty sure you do need a browser or something alike, like a WebView component on Android for example. If you're writing a desktop application, it must have some kind of WebView component to render the PDF. Since all rendering is done with HTML/CSS and JS, I assume you'll need a browser (component), but I'm not 100% sure.

If Yury/Brendan is reading, I think he can anwser your question in more detail.

mike

unread,
Aug 24, 2013, 7:53:26 AM8/24/13
to Tim van der Meij, dev-p...@lists.mozilla.org
Yes as I said after more reading I suspected that. Now what I'm
thinking is that a standalone app could be build with just the required
mozilla libraries perhaps by using xul to define the UI. I believe this
is how Celtx the media pre-production software is built. It is a
standalone application that does not run in a browser and that doesn't
act or look like a browser. The idea would be to use xul to pull in
just what is needed and to define the user interface. But it's been a
long time since I've looked at this and xul may be the wrong
configuration language, i.e., the language I'm thinking of might not be
xul. Maybe someone can tell me?

Best
Mike

mike

unread,
Aug 24, 2013, 7:58:50 AM8/24/13
to Tim van der Meij, dev-p...@lists.mozilla.org
In fact what I said about Celtx is true. See
http://en.wikipedia.org/wiki/Xul#XUL_applications. Again according to
wikipedia xaml is Microsoft's equivalent for xul.

My motivation for wanting to do this is that pdf.js can display files
that Adobe Reader can't. In addition I would like to be able to develop
standalone apps around pdf.js more generally.

Best
Mike

mike

unread,
Aug 24, 2013, 9:05:55 AM8/24/13
to Tim van der Meij, dev-p...@lists.mozilla.org
Well actually xul and the mozilla application framework ...

Best
Mike

Yury Delendik

unread,
Aug 24, 2013, 9:22:43 AM8/24/13
to mike, Tim van der Meij
On 8/24/2013 6:53 AM, mike wrote:

>> Op vrijdag 23 augustus 2013 23:07:54 UTC+2 schreef mike:
>>> What I mean by standalone is without a browser as an independent
>>> application.

What an independent application will do? If it's just for e.g. text
extraction or search then it's possible since no UI elements is required.

> Now what I'm
> thinking is that a standalone app could be build with just the required
> mozilla libraries perhaps by using xul to define the UI.

A web browser control is a part of XUL, so yes, you can use XULRunner.
Or even better, install and run PDF.js as a web application locally --
it will not have browser controls.

Support environments other than HTML5 is out of scope of the PDF.js
project, but you can try to re-write display portion of the project
(viewer.html/.js/.css and canvas.js) to use any available to you
frameworks. Core pdf.js library (document structure parsing) will run
without or with minor changes on any modern JavaScript engine.

Thanks,
Yury Delendik

mike

unread,
Aug 24, 2013, 9:29:05 AM8/24/13
to Yury Delendik, mozilla-d...@lists.mozilla.org, Tim van der Meij
On 24/08/2013 14:22, Yury Delendik wrote:
> On 8/24/2013 6:53 AM, mike wrote:
>
>>> Op vrijdag 23 augustus 2013 23:07:54 UTC+2 schreef mike:
>>>> What I mean by standalone is without a browser as an independent
>>>> application.
>
> What an independent application will do? If it's just for e.g. text
> extraction or search then it's possible since no UI elements is required.
>
>> Now what I'm
>> thinking is that a standalone app could be build with just the required
>> mozilla libraries perhaps by using xul to define the UI.
>
> A web browser control is a part of XUL, so yes, you can use XULRunner.
> Or even better, install and run PDF.js as a web application locally --
> it will not have browser controls.
>
> Support environments other than HTML5 is out of scope of the PDF.js
> project, but you can try to re-write display portion of the project
> (viewer.html/.js/.css and canvas.js) to use any available to you
> frameworks. Core pdf.js library (document structure parsing) will run
> without or with minor changes on any modern JavaScript engine.
>
> Thanks,
> Yury Delendik
> _______________________________________________
> dev-pdf-js mailing list
> dev-p...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-pdf-js
>
>
Thanks for the answers Yury. That's very helpful.

Best
Mike
0 new messages