Recommended Way to Embed Pdf in Html

Recommended way to embed PDF in HTML?

Probably the best approach is to use the PDF.JS library. It's a pure HTML5/JavaScript renderer for PDF documents without any third-party plugins.

Online demo:
https://mozilla.github.io/pdf.js/web/viewer.html

GitHub:
https://github.com/mozilla/pdf.js

Embedding pdf and images in html

I'm sure this is better suited to a comment, however I'm new and am working on unlocking that feature.

...however,
due to the fact that my html contains a form and the user has to be
able to decide whether he would like to upload a pdf-file or an image...

What are you using for the form (query language & database management)?

(PHP, Django, MySQL, MongoDB, etc)

Are there any other/better ways to embed a
pdf- or image-file in an html page?

I would recommend using embed or iframes. You are correct in thinking that the object tag is not an elegant solution, since you are dealing with images.

Edit: I want top display the pdf kind of like a file. Also, I don't
want the user to be able to resize the pdf in the viewer

Easy to do with iframes. There's a lot of hate when it comes to iframes. As you seem to plan on using it as a tool to display a file within a page, then I believe using an iframe here is just fine.

Check out this link on iframes. (will also tell you how to keep the user from resizing it)



Related Topics



Leave a reply



Submit