Introducing PDFObject

I recently worked on an e-learning course that required embedding some PDFs into an HTML file. PDF embedding piqued my curiosity, and has become something of a pet project. It sounds simpler than it is. No, scratch that… it is pretty simple. Stoopid simple. The problem is that there’s a lot of bad info about embedding PDFs floating around the www, especially regarding using the embed element.

Note to readers: embed bad, object good.

Unlike embedding SWFs, embedding a PDF is a breeze if you use the object element, and the object element has the added bonus of being totally standards-compliant.

As I tinkered on my new pet project, I decided it would be nice to have a JavaScript script that could dynamically embed PDFs as easily as SWFObject allows SWF embedding. I managed to whip up a script, and decided to name it PDFObject. (I know, I know… what a creative name!) As you may have inferred from the name, the concept and functionality is pretty similar to SWFObject. Like SWFObject, it’s also standards-friendly, and uses DOM scripting techniques to write a standard object element to the page.

One of the perks of using this script is that it makes working with PDF Open parameters much easier, similar to how SWFObject makes working with flashvars easier.

I’ve built a simple website for my PDFObject project named — drumroll, please — http://pdfobject.com. The most time-consuming part of this project has actually been building the website; it includes instructions, a ton of examples, and a compatibility table detailing results from browser/OS testing, including Mac OS X 10.5, Win XP, Vista, and Ubuntu. The site also features a section devoted to PDF embedding using standard HTML code without JavaScript (gotta promote standards!), and a handy code generator that makes writing the code as easy as filling out a form.

The site purposely does not include support or contact information; while I enjoy making things that help people out, I already know I don’t have the time to handle support issues. Sorry!

Anyway, PDFObject is completely free (as-is, no warranties) and my gift to the community. I hope some of you find it useful. :)

Possibly related journal entries:

4 Responses to “Introducing PDFObject”

  1. Tom

    Nice! Never thought about doing that kind of thing before, and it’s given me some good ideas for some problems I’ve had in the past.

    Thanks a lot!

  2. Aaron

    Well done, Philip!

  3. Al

    The big rectangle near the top of the PDFobject website is blank. I suppose something should be there. I’m using IE6 on Win 2000

  4. Philip Hutchison

    Thanks for the feedback. Yes, there’s a PDF embedded there. :)

    What version of Adobe/Acrobat Reader do you have installed?

Leave a Reply

Use my LAST NAME as the code. It can be found in the page footer. Be careful not to misspell it.

Comment moderation is in use. Please do not submit your comment twice — it will appear shortly.

Comments for this post will be closed on 30 November 2008.