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

I'd like to use pdf.js for a lot of PDFs on our site...

3,186 views
Skip to first unread message

harmo...@gmail.com

unread,
Feb 5, 2013, 11:11:09 AM2/5/13
to
Right now I have it set up so viewer.js has the DEFAULT_URL listed as a specific url to a PDF. What's the best way to have that variable populated with any PDF clicked on the page? I'm referring to this line specifically:

var DEFAULT_URL = 'http://url.com/specific.pdf';

(Explain it like I'm 5 years old...) Thanks!

Julian Viereck

unread,
Feb 5, 2013, 11:22:55 AM2/5/13
to harmo...@gmail.com, dev-p...@lists.mozilla.org
Look here:

https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L959

use `PDFView.open(yourURL)` to open a PDF from a specific URL. Note
that cross-origin policies apply when you load the PDF.

Not sure if this is for 5-year old, so let me know if you need more
help with it ;)

Very best,

Julian
> _______________________________________________
> dev-pdf-js mailing list
> dev-p...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-pdf-js

harmo...@gmail.com

unread,
Feb 5, 2013, 4:20:21 PM2/5/13
to harmo...@gmail.com, dev-p...@lists.mozilla.org
I tried putting that in with the link as: <a href="#" onclick="PDFView.open('/folder/chareth-cutestory.pdf');">Testy</a> but I have not had much luck (just navigates to "#"). Which .js files do I need to include on my page that has the pdf links on it?

(Please explain like I am 3 years old...) Thanks!

Julian Viereck

unread,
Feb 5, 2013, 4:33:58 PM2/5/13
to harmo...@gmail.com, dev-p...@lists.mozilla.org
You need to include the viewer.js Javascript file. What happens if you
execute `PDFView.open('/folder/chareth-cutestory.pdf');` in the
JavaScript console of your browser? Does this load the right PDF?

Can you make your app available somewhere, such that I can take a look
at it?

Best,

Julian

On Tue Feb 5 22:20:21 2013, harmo...@gmail.com wrote:
> I tried putting that in with the link as: <a href="#" onclick="PDFView.open('/folder/chareth-cutestory.pdf');">Testy</a> but I have not had much luck (just navigates to "#"). Which .js files do I need to include on my page that has the pdf links on it?
>
> (Please explain like I am 3 years old...) Thanks!

harmo...@gmail.com

unread,
Feb 5, 2013, 4:20:21 PM2/5/13
to mozilla.d...@googlegroups.com, dev-p...@lists.mozilla.org, harmo...@gmail.com

harmo...@gmail.com

unread,
Feb 6, 2013, 9:20:15 AM2/6/13
to harmo...@gmail.com, dev-p...@lists.mozilla.org
SyntaxError: Unexpected identifier

Looking at the errors that show up for viewer.js they are as follows:

watchScroll: function pdfViewWatchScroll(viewAreaElement, state, callback) {
state.down = true;
state.lastY = viewAreaElement.scrollTop;
• Uncaught Type Error: Cannot read property 'scrollTop' of null •

PDFView.animationStartedPromise = new PDFJS.Promise();
• Uncaught Reference Error: PDFJS is not defined •

Thanks again for all your assistance thus far!

harmo...@gmail.com

unread,
Feb 6, 2013, 9:35:45 AM2/6/13
to harmo...@gmail.com, dev-p...@lists.mozilla.org
Or "pdfView is not defined".

Julian Viereck

unread,
Feb 6, 2013, 11:05:39 AM2/6/13
to harmo...@gmail.com, dev-p...@lists.mozilla.org

On 2/6/13 3:20 PM, harmo...@gmail.com wrote:
> SyntaxError: Unexpected identifier
>
> Looking at the errors that show up for viewer.js they are as follows:
>
> watchScroll: function pdfViewWatchScroll(viewAreaElement, state, callback) {
> state.down = true;
> state.lastY = viewAreaElement.scrollTop;
> � Uncaught Type Error: Cannot read property 'scrollTop' of null �
>
> PDFView.animationStartedPromise = new PDFJS.Promise();
> � Uncaught Reference Error: PDFJS is not defined �
>
> Thanks again for all your assistance thus far!
Do you have the PDF.JS file included and do you reuse the html from the
viewer.html? Just including the viewer.js on your site is not enough.

Best,

Julian

harmo...@gmail.com

unread,
Feb 6, 2013, 11:17:35 AM2/6/13
to harmo...@gmail.com, dev-p...@lists.mozilla.org
Alright. How can I get the link to open the viewer on a new page with the PDF that is defined in the parameters? pdf.js and viewer.js are included and the link has the javascript with the pdfView.Open('url.pdf'); onclick.

I apologize, I am new to the scene. Your instruction has been invaluable so far.
Message has been deleted

harmo...@gmail.com

unread,
Feb 6, 2013, 9:20:15 AM2/6/13
to mozilla.d...@googlegroups.com, dev-p...@lists.mozilla.org, harmo...@gmail.com
SyntaxError: Unexpected identifier

Looking at the errors that show up for viewer.js they are as follows:

watchScroll: function pdfViewWatchScroll(viewAreaElement, state, callback) {
state.down = true;
state.lastY = viewAreaElement.scrollTop;
• Uncaught Type Error: Cannot read property 'scrollTop' of null •

PDFView.animationStartedPromise = new PDFJS.Promise();
• Uncaught Reference Error: PDFJS is not defined •

harmo...@gmail.com

unread,
Feb 6, 2013, 9:35:45 AM2/6/13
to mozilla.d...@googlegroups.com, dev-p...@lists.mozilla.org, harmo...@gmail.com
Message has been deleted
Message has been deleted

harmo...@gmail.com

unread,
Feb 8, 2013, 11:31:04 AM2/8/13
to harmo...@gmail.com, dev-p...@lists.mozilla.org
Welp, turns out it was this easy:

https://github.com/mozilla/pdf.js/issues/2496

harmo...@gmail.com

unread,
Feb 8, 2013, 11:31:04 AM2/8/13
to mozilla.d...@googlegroups.com, dev-p...@lists.mozilla.org, harmo...@gmail.com

namei

unread,
Feb 17, 2013, 12:40:02 AM2/17/13
to dev-p...@lists.mozilla.org, harmo...@gmail.com
@harmo...@gmail.com

hello,

would you be able to lend your expertise to this question:

https://groups.google.com/d/topic/mozilla.dev.pdf-js/v0xJsckv1tI/discussion

as i think you have implemented what i am trying to implement.

as a newb, i think i will need all steps and code examples eg:

1. script resources to include in head.
2. script to use in head.
3. files required to be on server.
4. the construction of the pdf links

thank you!

namei

unread,
Feb 17, 2013, 12:40:02 AM2/17/13
to mozilla.d...@googlegroups.com, dev-p...@lists.mozilla.org, harmo...@gmail.com
0 new messages