tags:

views:

55

answers:

1

I have a page where I need to display a pdf and an "I agree" button.

Q: Do I use cfpdf to create a thumbnail of the pdf and display the resulting output?

Chapter 32 of cfWack 8 talks about using cfpdf.

+1  A: 

I did this in the office once...It's not that sweet as it's presented in Adobe's whitepapers.

Here's my code:

<cfpdf source="#attachmentFilePath##attachmentFilename#" pages="1" imagePrefix="#prefix#" action="thumbnail" destination="#application.attachmentsFilePath#/_thumbs" format="jpg" overwrite="true" resolution="low" scale="80">

                    <cfset thumbURL = "http://127.0.0.1:9001/attachments/_thumbs/#prefix#_page_1.jpg"&gt;

                    <cfif fileExists(thumb)>

                        <tr>
                            <td width="100%">
                                <a href="attachmentView.cfm?attachNo=#attachNo#&act=download">
                                    <img alt="#attachmentFilename#" src="#thumbURL#" width="500" />
                                </a>
                            </td>
                        </tr>

                    <cfelse>

                        <cfheader name="Content-Type" value="#attachmentMIMEType#">
                        <cfheader name="Content-Disposition" value="attachment; filename=#attachmentFilename#">
                        <cfcontent type="#attachmentMIMEType#" file="#attachmentFilePath##attachmentFilename#">

                    </cfif>

I also check isPDF() and putting all this in try/catch.

So what's wrong with this? It works with 30% of PDF users are trying to preview so in catch I display link for download instead of image :(

zarko.susnjar
I took a new approach. I made the "I accept" button hidden until they click on the link to the pdf.
cf_PhillipSenn