RussCoder/djvujs

example

Closed this issue · 1 comments

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.

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:

  • loadDocument(buffer, name) - which accepts the ArrayBuffer and a name of a document which should be shown at footer(it's optional).
  • async loadDocumentByUrl(url) - which loads the documents as an ArrayBuffer and then invokes the previous 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. И если что, то я говорю по-русски лучше, чем по-английски.