Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

how to embed pdf in html

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Saloon Keeper
Posts: 2662
130
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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...
 
Amit Sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you now trying to do this? As was mentioned before, OBJECT and EMBED do not support PDFs.
 
Amit Sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually i am using this one

test.pdf

 
Amit Sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not able to display exact code. That was href tag
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Mr. Ulf hinted, HTML doesn't support embedding PDF in pages.
 
salvin francis
Saloon Keeper
Posts: 2662
130
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amit,

what if you have a link whose href is a pdf file,
what happens when you click that link ?
 
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic