Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with loadDocumentByUrl #92

Open
aalexei opened this issue Jan 7, 2024 · 6 comments
Open

Error with loadDocumentByUrl #92

aalexei opened this issue Jan 7, 2024 · 6 comments

Comments

@aalexei
Copy link

aalexei commented Jan 7, 2024

Hi, I'm trying to set up a viewer for djvu files I serve on a local url line /file/uid.djvu. Using the code

 const viewer = new DjVu.Viewer();
 viewer.render(document.getElementById('djvu-view'));
 viewer.loadDocumentByUrl('/file/{{fuid}}.djvu');

but I just get the error:

Unexpected error
{}

What am I doing wrong?

@RussCoder
Copy link
Owner

Hello, is the code processed by a template engine? I'm asking because of the string '/file/{{fuid}}.djvu'.
Try to hardcode the URL and try to open another file.

@aalexei
Copy link
Author

aalexei commented Jan 9, 2024

Same error, and I've checked it all get's expanded correctly and there is a file at that url.

@aalexei
Copy link
Author

aalexei commented Jan 9, 2024

The following variant works, but requires loading data into array buffer:

async function loadDocument1() {
     // Working
     const viewer = new DjVu.Viewer();
     viewer.render(document.getElementById('djvu-view'));
     const indexFileBuffer = await fetch('/file/{{fuid}}').then(r => r.arrayBuffer());
     await viewer.loadDocument(indexFileBuffer);
 }

 async function loadDocument2() {
     // Not working
     const viewer = new DjVu.Viewer();
     viewer.render(document.getElementById('djvu-view'));
     await viewer.loadDocumentByUrl('/file/{{fuid}}');
 }

loadDocument1();

So seems to be something with the parsing of the url?

@RussCoder
Copy link
Owner

Please, check the browser console (Ctrl+Shift+I). I need more information.
And is it a bundled (single file) document or an indirect (multifile) one?

@aalexei
Copy link
Author

aalexei commented Jan 11, 2024

This is using the js files from https://djvu.js.org/downloads (DjVu.js 0.5.4, DjVu.js Viewer 0.10.0).

Console reports

TypeError: invalid type format
    at DE (djvu_viewer.js:134:4404)
    at Op.loadDocumentByUrl (djvu_viewer.js:134:17798)
    at loadDocumentByUrl.next (<anonymous>)
    at h (djvu_viewer.js:134:1351)
    at E (djvu_viewer.js:134:1910)
errorAction @ djvu_viewer.js:78
loadDocumentByUrl @ djvu_viewer.js:134
h @ djvu_viewer.js:134
E @ djvu_viewer.js:134
Promise.then (async)
bc @ djvu_viewer.js:131
v @ djvu_viewer.js:134
y @ djvu_viewer.js:134
h @ djvu_viewer.js:134
E @ djvu_viewer.js:134
(anonymous) @ djvu_viewer.js:131
YC @ djvu_viewer.js:131
Qg @ djvu_viewer.js:131
Gg @ djvu_viewer.js:131
Xg.e.put @ djvu_viewer.js:131
(anonymous) @ djvu_viewer.js:134
(anonymous) @ djvu_viewer.js:131
(anonymous) @ djvu_viewer.js:134
loadDocumentByUrl @ djvu_viewer.js:134
loadDocument2 @ UGMDGMH1C25FXGNTWGI1UVEHY:160
(anonymous) @ UGMDGMH1C25FXGNTWGI1UVEHY:162

@RussCoder
Copy link
Owner

I forgot about this issue. Sorry for that.
If you still need it to be solved, please, send me the file. Or at least tell me its type (bundled or indirect) and the final URL that is used to load it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants