ColdFusion 8: CFPDF, tumbnails and tooltips
Posted At : June 4, 2007 7:05 AM
| Posted By : Dave
Related Categories:
ColdFusion
I have been checking out the ability to thumbnail pdf files. Currently I am very impressed with the accuracy and speed. I was able to thumbnail every page of a 27 page pdf in only 4 seconds. While I was working on checking all this out Ray Camden blogged about the new tooltip function. This got me to thinking, could I couple the pdf thumbnailing with a tooltip?
Here is what I came up with. First thing, before using the code create, a "thumbs" and a "temp" directory in the same directory as the code. Then take a pdf and put it in the same directory as the code. Make sure the var "pdfFile" has the name of your pdf file.
The first part is the thumbnail generator and display. This processes the pdf and creates thumbnails and lays them out 7 per row.
<CFSET pdfFile = "test.pdf">
<CFPDF ACTION="READ" NAME="testPDF" SOURCE="#expandPath('.')#\#pdfFile#">
<CFPDF ACTION="GETINFO" NAME="testInfo" SOURCE="testPDF">
<CFPDF ACTION="THUMBNAIL" SOURCE="testPDF" FORMAT="PNG" DESTINATION="#expandPath('.')#\thumbs" SCALE="15" OVERWRITE="YES" IMAGEPREFIX="img">
<CFOUTPUT>
<CFLOOP INDEX="x" FROM="1" TO="#testInfo.TotalPages#">
<CFIF x mod 7 EQ 1><BR></CFIF>
<cftooltip sourcefortooltip="preview.cfm?id=#x#&pdf=#pdfFile#" PREVENTOVERLAP="TRUE"><IMG SRC="./thumbs/img_page_#x#.png" BORDER="1"></cftooltip>
</CFLOOP>
</CFOUTPUT>
This is the code for preview.cfm. It generates an image for a specific page in the pdf. I toyed with using cfimage to enlage the thumbnail but the output was not good.
<CFPDF ACTION="THUMBNAIL" SOURCE="#expandPath('.')#\#url.pdf#" FORMAT="PNG" PAGES="#url.id#" DESTINATION="#expandPath('.')#\temp" SCALE="75" OVERWRITE="YES" IMAGEPREFIX="img">
<CFOUTPUT><IMG SRC="./temp/img_page_#id#.png" BORDER="0"></CFOUTPUT>
Unfortunately, there are some things about this that I do not like. For starters the JS for the tooltip is bloated. There is also some very weird display issues with the tooltip. I am not sure that the tooltip stuff is ready for prime time. However, PDF thumbnailing is amazing.
--Dave

--Dave
Yes, we do see the issues you were facing.
The issue with overlapped tooltips is a genuine one and we will be working on resolving it but the other issue is more a result of bigger size thumbnailed PDF's. We will see
what we can do here but changing the scale attribue to 50% or so, should result in proper behavior.
Let us know if you find anything else.
Thanks,
Vamsee