aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes how to embed pdf in html Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to embed pdf in html" Watch "how to embed pdf in html" New topic
Author

how to embed pdf in html

Amit Sharma
Ranch Hand

Joined: Nov 22, 2005
Posts: 87
Hi
Is there any way to embed pdf file in html. so that i can view it in browser.
I have used following tags but these are not supported in many browsers.


<object data="test.pdf" type="application/pdf" width="300" height="200"> </object>

<embed src="test.pdf" type="application/pdf"></embed>


Amit Sharma SCJP 1.4, SCWCD 5, OCUP-100(UML)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41574
    
  54
HTML has no provisions for embedding PDFs. You can provide a link to the PDF; and then it either gets downloaded, or it may get displayed in the browser if there's a plugin for PDFs. That's dependent on the browser configuration, though, and there's nothing the web app can do about it.


Ping & DNS - my free Android networking tools app
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

Amit Sharma wrote:... but these are not supported in many browsers...

I doubt this is a browser feature,

I think you will have different results with a machine having IE7 installed with no pdf readers vs a machine having IE7 with adobe acrobat installed
if that's the case, this is not a browser issue...


My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
Amit Sharma
Ranch Hand

Joined: Nov 22, 2005
Posts: 87
But i have adobe acrobat installed on my machine and firefox and IE7 . still i am not able to see the pdf in browser.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41574
    
  54
How are you now trying to do this? As was mentioned before, OBJECT and EMBED do not support PDFs.
Amit Sharma
Ranch Hand

Joined: Nov 22, 2005
Posts: 87
Actually i am using this one

test.pdf

Amit Sharma
Ranch Hand

Joined: Nov 22, 2005
Posts: 87
not able to display exact code. That was href tag
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41574
    
  54
So what happens if you click the link? As I said before, the browser may be set to download and save PDFs silently; check its default download directory.
Amit Sharma
Ranch Hand

Joined: Nov 22, 2005
Posts: 87
Yes Ulf when i am clicking that link that pdf get opened in a new window(not in the browse window).
But that is not the exact solution i am looking for, actually i want to display it in browser only. Is it possible.
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

As Mr. Ulf hinted, HTML doesn't support embedding PDF in pages.
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

Amit,

what if you have a link whose href is a pdf file,
what happens when you click that link ?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to embed pdf in html