PDFObject is a JavaScript utility I created in 2008 to embed PDFs in HTML documents. It was modeled on SWFObject.
Three years have passed since PDFObject 1.0 was released, and the browser landscape has changed dramatically. I figured it’s time to dust off PDFObject and see if it can be improved and/or updated for today’s browsers.
I’ve placed a modified edition of PDFObject (version 1.1) on GitHub as an open-source project, allowing anyone to create a fork and make modifications. There are also a handful of example/test HTML files there, too. I could use some help testing the examples in different OS/browser combinations, and with different PDF plugins.
If you have suggestions for improvements, or have a few minutes to test PDFObject examples in your browser/OS of choice, I’d be grateful to hear from you. Just leave a comment below, or send me a message on twitter. So far I’ve only performed some cursory tests in Firefox 3.6 in OSX 10.6.6, but everything seems to work as expected.
https://github.com/pipwerks/PDFObject
I plan to update PDFObject.com soon, too.
Comments
Chris wrote on March 25, 2011 at 11:04 am:
I just found this and it's great. Working good for me in Firefox/Safari/IE, but it's having problems in Chrome. Can't zoom set for the PDF. It's always at 100%.
philip wrote on March 25, 2011 at 12:26 pm:
@chris, thanks. i'll look into it. what are you using? Adobe Reader on a PC, Preview on a Mac, etc?
Chris wrote on March 28, 2011 at 5:44 am:
@philip Adobe Reader on Windows 7.
Chris wrote on April 8, 2011 at 8:50 am:
@philip Ah, it's because Chrome is using it's own PDF Viewer plugin by default instead of the Adobe plugin.
about:plugins and disable Chrome PDF Viewer
Vincent wrote on April 20, 2011 at 6:47 pm:
I found out your plugin yesterday, we are looking for a good way to show PDF on a website and it seems like there's no good solution. I'm my search I found out that tag is getting back with HTML5 and it seems to be better than , what do you tink of this? Maybe you could improve your plugin so that if browser support HTML5 it render a embed tag? I'm on Win7 and it works fine everywhere except on firefox4, it just don't work with object, even the alternate html with the link does'nt get rendered. But if I trywith embed in FF4 it works.
What's even stranger is that with youre plugin it works, it's just when I write it by my self. Anyway I'm interested about what you think of HTLM5 and I also like to know what's the advantage of using the plugin vs HTML?
Thanks!
Vincent wrote on April 20, 2011 at 7:09 pm:
Just want to let you know that the problem is using height=xx% in Firefox…
philip wrote on April 20, 2011 at 7:18 pm:
@vincent yeah, firefox requires you to specify the height of the object's parent container via CSS or else your object's height will seem broken.
Andrew Carr wrote on July 13, 2011 at 4:49 am:
Is there any plan to make PDFObject work with the Chrome PDF Viewer?
philip wrote on July 13, 2011 at 10:21 am:
@andrew PDFObject includes support for the PDF mime type (not just Adobe Reader) so it should support Chrome's PDF Viewer. However, Chrome's PDF Viewer is very new, so I haven't performed any tests to confirm functionality. I'll certainly look into it, but I have no timeline at the moment.
miz-d wrote on July 18, 2011 at 2:40 am:
Hi Philip.
While using PDFobject viewer i have discrepancy in disabling the toolbar option especially in google chrome browser. Can you please look into the matter @ earliest.
Mike wrote on July 20, 2011 at 2:53 pm:
Hey Phillip,
First off, I love your PDFObject Script. It's awesome. However, I am having trouble trying to make my PDFObjects dynamic by passing a parameter from an xml file into my function, which then embeds a PDF by the name of said parameter.
Here is a sample of my code:
function set_skins(datas) {
var temps=document.createElement("DIV");
temps.innerHTML="{url: '" + datas +".pdf'}";
var myPDF = new PDFObject(mebbe).embed("skins");
}Where 'datas' is the name of the file (without the '.pdf') that is passed from my xml file into my function, which I would like to embed.
I've been searching for work-arounds, but to no avail thus far. I'll continue to search, but any assistance or direction would be much appreciated.
Thanks for everything!
-Mike
philip wrote on July 29, 2011 at 10:54 am:
I've done some quick testing in Chrome (12, Mac OS X) and can confirm that PDFObject works as expected. However, Chrome does not support PDF Open parameters, which means you can't script the toolbar to show/hide, or script the PDF to show a specific search term. This functionality is completely controlled by the PDF viewer (in this case by Google Chrome) and is not a bug in PDFObject.
I just found this and it’s great. Working good for me in Firefox/Safari/IE, but it’s having problems in Chrome. Can’t zoom set for the PDF. It’s always at 100%.
@chris, thanks. i’ll look into it. what are you using? Adobe Reader on a PC, Preview on a Mac, etc?
@philip Adobe Reader on Windows 7.
@philip Ah, it’s because Chrome is using it’s own PDF Viewer plugin by default instead of the Adobe plugin.
about:plugins and disable Chrome PDF Viewer
I found out your plugin yesterday, we are looking for a good way to show PDF on a website and it seems like there’s no good solution. I’m my search I found out that tag is getting back with HTML5 and it seems to be better than , what do you tink of this? Maybe you could improve your plugin so that if browser support HTML5 it render a embed tag? I’m on Win7 and it works fine everywhere except on firefox4, it just don’t work with object, even the alternate html with the link does’nt get rendered. But if I trywith embed in FF4 it works.
What’s even stranger is that with youre plugin it works, it’s just when I write it by my self. Anyway I’m interested about what you think of HTLM5 and I also like to know what’s the advantage of using the plugin vs HTML?
Thanks!
Just want to let you know that the problem is using height=xx% in Firefox…
@vincent yeah, firefox requires you to specify the height of the object’s parent container via CSS or else your object’s height will seem broken.
Is there any plan to make PDFObject work with the Chrome PDF Viewer?
@andrew PDFObject includes support for the PDF mime type (not just Adobe Reader) so it should support Chrome’s PDF Viewer. However, Chrome’s PDF Viewer is very new, so I haven’t performed any tests to confirm functionality. I’ll certainly look into it, but I have no timeline at the moment.
I’ve done some quick testing in Chrome (12, Mac OS X) and can confirm that PDFObject works as expected. However, Chrome does not support PDF Open parameters, which means you can’t script the toolbar to show/hide, or script the PDF to show a specific search term. This functionality is completely controlled by the PDF viewer (in this case by Google Chrome) and is not a bug in PDFObject.
Hi Philip.
While using PDFobject viewer i have discrepancy in disabling the toolbar option especially in google chrome browser. Can you please look into the matter @ earliest.
Hey Phillip,
First off, I love your PDFObject Script. It’s awesome. However, I am having trouble trying to make my PDFObjects dynamic by passing a parameter from an xml file into my function, which then embeds a PDF by the name of said parameter.
Here is a sample of my code:
function set_skins(datas) {
var temps=document.createElement(“DIV”);
temps.innerHTML=”{url: ‘” + datas +”.pdf’}”;
var myPDF = new PDFObject(mebbe).embed(“skins”);
}
Where ‘datas’ is the name of the file (without the ‘.pdf’) that is passed from my xml file into my function, which I would like to embed.
I’ve been searching for work-arounds, but to no avail thus far. I’ll continue to search, but any assistance or direction would be much appreciated.
Thanks for everything!
-Mike