logoalt Hacker News

rahkiinyesterday at 3:33 PM3 repliesview on HN

I recently needed to show a pdf file inside a div in my app. All i wanted was to show it and make it scrollable. The file comes from a fetch() with authorzation headers.

I could not find a way to do this without pdf.js.


Replies

silverwindyesterday at 11:40 PM

https://www.npmjs.com/package/pdfobject works well as a wrapper around the <object> tag. No mobile support though.

rahkiinyesterday at 3:57 PM

This made me try it once more and I got something to work with some Blobs, resource URLs, sanitazion and iframes.

So I guess it is possible

show 1 reply
moi2388yesterday at 3:41 PM

The html object tag can just show a pdf file by default. Just fetch it and pass the source there.

What is the problem with that exactly in your case?

show 1 reply