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
Fixed Position Relative to Parent Container
How to Prevent Desktop Browser (Chrome, Safari) from Zooming a Webpage
How to Type Text With Hat "^" in HTML
How to Make All Images of Different Height and Width the Same Via CSS
How to Remove Outline in Bootstrap 4
Limit the Size of a File Upload (Html Input Element)
How to Remove Free Spaces Between Divs
Selecting an Option in a Dropdown List Using Request Parameters
Using Mailto to Send Email With an Attachment
How to Position Elements Next to Each Other in a Div
How to Place Div in Top Right Hand Corner of Page
Table With Fixed Header and Fixed Column on Pure CSS
How to Prevent Flex-Items from Overflowing Flex Parent With No Wrap
How to Remove All Script Tags from HTML File
Make Content Horizontally Scroll Inside a Div