UniversalViewer / universalviewer

A community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
http://universalviewer.io
Other
500 stars 191 forks source link

Does UV read the PDF file, or only IIIF images? #1115

Open ljsherlock opened 1 month ago

ljsherlock commented 1 month ago

Sorry if this is not really an issue. I'm using UV for a project where we are creating our own manifests, which are working fine.

PDFJS complains that the PDF is corrupted. While looking at the example manifests from UV it includes IIIF images of each page as well as the PDF which can be downloaded.

So my main question is, can the PDF as a file be viewed by the UV, or is it only for download purposes? Do we in fact need to create images for each page in order to view it?

Anyone's knowledge on this would be a great help. Thanks in advance!

demiankatz commented 1 month ago

You can do it either way: IIIF images with PDF as a download option via renderings, or PDF-only.

The UV supports a non-standard "IxIF" format for PDF files, which is used by Villanova's manifests; here is an example:

https://digital.library.villanova.edu/Item/vudl:294631/Manifest

You can see it in action here:

https://digital.library.villanova.edu/Item/vudl:294631

It's possible there is a better, more modern approach, but since our existing manifests still work, I have not investigated changing them yet.

Also note that there is a setting controlling whether UV uses PDF.js or PDFObject. PDF.js is the default, but Villanova uses PDFObject due to performance problems we encountered with PDF.js.

ljsherlock commented 1 week ago

Thanks @demiankatz for the information. Very appreciated.

ljsherlock commented 1 week ago

By the way. I notice that the manifest you referenced serves multiple PDFs in one manifest.

Do you know of a way to alter the manifest for one file where the PDF pages come up in the sidebar instead, or is that something only possible with the IxIF format for PDF files?

Thanks again in advance for any knowledge you can share.

demiankatz commented 1 week ago

@ljsherlock, I'm not sure if the mode you describe is possible; as noted earlier, there are two PDF integrations: PDFObject vs. pdf.js. The PDFObject version uses the browser's native PDF capabilities, whatever they happen to be, so it gives no control over the presentation of the file. The pdf.js renders the file in-browser using a library, so it may be possible to customize that to achieve the view you desire (but I'm not sure, because I don't personally use that version due to past experience with performance issues).