How to embed a PDF in HTML page?

user339108 picture user339108 · Apr 6, 2011 · Viewed 93.4k times · Source

We would like to show the PDF document in an HTML page after retrieving it from the database via a servlet's doGet method.

Can anyone share some snippets on how to achieve this?

Answer

mplungjan picture mplungjan · Apr 6, 2011

Non-html content apart from images needs to be retrieved using an object, embed or iframe tag

  1. iframe: <iframe src="somepage.pdf"></iframe>
  2. object/embed: <object src="somepage.pdf"><embed src="somepage.pdf"></embed></object>

somepage.pdf could be somepage.jsp?filename=somepage&mimetype=application/pdf

Here is an interesting link How to Embed Microsoft Office or PDF Documents in Web Pages

and here is a stackoverflow search