Site icon StartFunction

Display PDF using Thickbox in a WordPress plugin

The ILC-PDFBox plugin for WordPress will allow you to display a PDF document that you embed in the post writing area using Thickbox, the jQuery modal window. In this way you don’t have to open a separate page to display it, you can speed up loading times by loading it only if it’s going to be read and you don’t waste excessive bandwidth.

All you have to do in order to use it, is uploading and installing it like any other plugin. Then, in the post writing area, just upload your pdf using the “Add Media” button, the one with the asterisc, and insert the link to the file. That’s it. Publish your post and when you now click the link, a Thickbox displaying your pdf will be launched.

There are a few options for the plugin, accesible from the menu SettingsPDFBox Options. Here you can set the width and height of the Thickbox and add a custom CSS style. In addition to the .thickbox class added to the anchor, a .pdfbox class is added, in case you want to stylize it differently.
Finally, here’s a demo of the plugin in action. The first link displays the pdf using Thickbox and the second one is a feature requested by one of the readers on the comments, a direct link to download the pdf file.

Launch PDF file in Thickbox

So, without further ado, here’s the ILC-PDFBox plugin for WordPress, download it, play with it, and let me know what you think about it.

This plugin was tested using WordPress 3.0.1, 2.9.2, 2.8, so it should be fine.

Update 5-09-10

Due to some glitches regarding pdf embedding on the fly in IE, this won’t correctly display the pdf file within a Thickbox in IE. However, your users will still be able to view the pdf by clicking on the Download PDF link.

There is a solution to this issue: integrating it with ColorBox, a IE6-8 compatible solution for dialogs. The plugin will be updated in the next days to support ColorBox.

End Update 5-09-10
Exit mobile version