Embed PDF in HTML
<object data="myfile.pdf" type="application/pdf" width="100%" height="100%">
<p>It appears you don't have a PDF plugin for this browser.
No biggie... you can <a href="myfile.pdf">click here to
download the PDF file.</a></p>
</object>
for more details and examples.. visit this URL: http://pdfobject.com/markup/index.php
Related videos on Youtube
gene b.
Updated on July 09, 2022Comments
-
gene b. almost 2 years
I need to embed a PDF document inside an HTML page. The PDF is dynamically generated, i.e., not a static file, but rather a byte-array generated using a PDF toolkit (in my case, "Apache PDFBox"). I have a Java Web app.
From what I understand, there are 2 ways to embed a PDF: using the OBJECT and IFRAME tags.
The
<object>
tag does not work for me. When I have a dynamically-generated source, it takes 20 sec. to render. I'm not sure if that is a problem of the Acrobat Reader plugin, but I have not been able to get around this strange behavior.The
<iframe>
tag works fine and displays the PDF. But here's the problem: My PDF has a Submit button which submits the form. After I submit the form, I need to re-display the PDF with some kind of status message. The form output goes to the same frame. Thus, I get a Frame-inside-a-Frame. There is no way to break out of the current frame, because I don't have access to the<form>
tag. The form is contained inside the PDF and Acrobat takes care of submitting the form. If I have extra elements in my frame, such as a text message, I will get cascading frames.
Any ideas how to resolve this?
-
Dave almost 11 yearsTo make the iframe option work, you could add some javascript to your results page to break out of the frame. The object is the better option though; more likely to play nice with the browser. I do wonder if PDF is the right choice here; it's usually for printed documents.