Closed DanielRuf closed 10 years ago
There are no methods available in viewer.js
that do what you ask, you will have to implement them yourself.
PS. The link didn't work, so I fixed what appeared to be a typo by changing "pxf" to "pdf".
So there are no options in pdf.js or viwer.js which change or set the parameters in the url? If there are some which I could use then I could easily write the missing parts in JavaScript
The ?file=
part of the URL is only read when the HTML document loads, see: https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L1466. I suppose that you could try modifying the setHash
function: https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L1114.
There is no function that explicitly sets the URL. The updateViewarea
function changes the current URL of the viewBookmark
button, see: https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L1740.
Note that the only thing that this button displays is the URL of the current position in the document.
so generally this would be a new feature request, adding support for multiple docments in one viewer using a dropdown?
so generally this would be a new feature request, adding support for multiple docments in one viewer using a dropdown?
I don't think this is a feature that is necessary, or even should be included, in PDF.js by default. I cannot see a use case that warrants adding that kind of functionality (with the accompanying cluttering of the UI) to the default PDF Viewer that is shipped in Firefox.
Since PDF.js is open source, you are obviously free to implement this functionality in your own PDF.js viewer!
Ok thanks, will try this.
Closing as fixed. It seems to be working now on your website, and on top of that, like @Snuffleupagus said, there isn't really a way in which we can/want to include this in PDF.js. Most users will want to open a single file and change the file using the Open button. Indeed, if you want this functionality, you can build it in youself (like you already seem to have done). If there are issues remaining, please open a new issue.
Fixed? It is not working on my website. seems you have not read my issue carefully.
I have not yet starting to work on this. And what about the viewer? There are many accepted pull requests which added new features to it. My issue was meant as feature request for the viewer.
And what about the viewer? There are many accepted pull requests which added new features to it. My issue was meant as feature request for the viewer.
Yes, but you can also look at this the other way: there are quite a few PRs, that adds features to the default viewer, which are declined since they are not deemed necessary in the default viewer. What you propose is, in my opinion, functionality that might be relevant in a custom deployment of PDF.js, but does not make sense to include in the default PDF Viewer in Firefox.
@DanielRuf My apologies, I thought the switching didn't work, but the URL parameter was giving you trouble. I've reopened the issue so other developers can also take a look at it.
About the functionality, I agree with @Snuffleupagus that this is a nice feature for a custom viewer, but not for the default viewer used in, for example, Firefox.
Maybe @brendandahl or @yurydelendik can step in for the URL issue?
What JavaScript method calls do I need to add so that changing the value of the dropdown field also changes the file parameter in the url and if loaded using this url that it then loads the right file from the dropdown and autoselects the option?
Calling PDFView.open(newFile)
will close old pdf and open a new PDF file. See https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L627. Closing as answered.
@yurydelendik I know this, but does this update the value of the parameter in the url? But might be already solved as this was many months ago.
See http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#the-history-interface pushState/replaceState's url argument documentation
I know this, but updating the file parameter automatically is currently not part of the pdf.js viewer? Did not try this. Anyway, isn't important to me anymore. Just asking about the current implementstion eith the file parameter in the url.
We are not planning adding dropdown with files selector, so I guess, this problem will not exist for us. We glad to hear it's not a problem for you anymore. Thanks
Take a look at http://pdf.daniel-ruf.de and also on the corresponding repository here on my GitHub account.
I have a second dropdown / select field for loading different files next to the one for the zooming levels.
What JavaScript method calls do I need to add so that changing the value of the dropdown field also changes the file parameter in the url and if loaded using this url that it then loads the right file from the dropdown and autoselects the option?