Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed a PDF viewer in a page?

Tags:

html

pdf

If I'm not mistaken, Google Docs offers the means to display a PDF that is stored on the same server as the web page via an <iframe>, but I need to know how I can do this in a cross-browser compliant way.

like image 462
Andrei Oniga Avatar asked Dec 29 '12 11:12

Andrei Oniga


People also ask

How do I embed a PDF viewer on my website?

One popular option is that you upload the PDF file to an online storage service, something like Google Drive or Microsoft's OneDrive, make the file public and then copy-paste the IFRAME code provided by these services to quickly embed the document in any website.

Can you embed a PDF in pages?

When working in the Pages application, which is part of Apple's iLife suite of productivity software, you can embed images into your word processing and layout documents. Pages treats PDF files like all other image formats, so you can import them through the Insert menu.

How do I turn a PDF into an embedded link?

Choose Tools, click on Edit PDF, then on Link, and finally, select Add/Edit Web or Document Link. Select the area that you want to hyperlink. Then, in the Create Link dialog box, choose the options you want for the link appearance and click on the Open a Web Page button for the link action. Hit Next and enter the link.

How do I display a PDF on a Web page?

To embed the PDF in the HTML window, point the page to a document and then specify the height and width of the PDF so the HTML window is the correct size using the code: <embed src="filename. pdf" width="500" height="375">. Note that an embedded PDF may look very different on different browsers and operating systems.


2 Answers

You could consider using PDFObject by Philip Hutchison.

Alternatively, if you're looking for a non-Javascript solution, you could use markup like this:

<object data="myfile.pdf" type="application/pdf" width="100%" height="100%">   <p>Alternative text - include a link <a href="myfile.pdf">to the PDF!</a></p> </object> 
like image 134
Ian Gregory Avatar answered Oct 27 '22 00:10

Ian Gregory


PDF.js is an HTML5 technology experiment that explores building a faithful and efficient Portable Document Format (PDF) renderer without native code assistance. It is community-driven and supported by Mozilla Labs.

You can see the demo here.

like image 23
mutil Avatar answered Oct 26 '22 23:10

mutil