RussCoder / djvujs

DjVu.js is a program library for working with .djvu files online without any connection with the server. DjVu.js Viewer is a widget that allows viewing .djvu files right in the browser and can be easily embedded into any web page.
https://djvu.js.org/
Other
183 stars 36 forks source link

example #10

Closed chekanov closed 6 years ago

chekanov commented 6 years ago

Hello,

This looks interesting library. This is not an issue, but a question: is any html example that shows how to open a djvu file which is located on the server? The example with download works fine. But I want view a file which is already located in the same server with djvujs library.

RussCoder commented 6 years ago

Hello.

I have to say that the library itself does't work with remote resources at all. It works only with ArrayBuffer representing a document. It's up to you how you will get the file from the server.

If you are asking whether there is some API of the viewer to open a file by URL, then yes, there is such a possibility.

The viewer has two methods:

Thus, to load a document programmatically you can do the following:

DjVu.Viewer.init(document.getElementById('for_viewer'));
DjVu.Viewer.loadDocumentByUrl('assets/my-djvu-file.djvu');

Also you can load the file by your own and then use the loadDocument method. However in case of the loadDocumentByUrl you will see a progress bar of loading, if your file is rather big.

If you have more questions, feel free to ask.

P.S.: I'm going to change the API a bit in order to provide a possibility to create many instances of the Viewer, but when I do it, I will update the example on the website. I have just created a release with the current version as well. И если что, то я говорю по-русски лучше, чем по-английски.