1

PDFFileNotFoundException Inside IsPDFFile and IsPDFObject

I’m having a heck of a time using pdf document variables in CF 8.0.1 on Mac OS X 10.5 and Redhat Linux ES 5.  Those are the only platforms I have to test cf with so perhaps this is a windows issue as well.

From Adobe’s IsPDFObject documentation, I’ve taken their example of reading in a file as a pdf object and writing it out.  I’ve even gone the extra step of making sure cf thinks the input file is a valid pdf.


<cfif IsPDFFile("filein.pdf")>
<cfpdf source="filein.pdf" action="read" name="myPDFform"/>
<cfif IsPDFObject(myPDFform)>
<cfpdf source=#myPDFform# action="write" destination = "fileout.pdf">
<cfelse>
<p>This is not a PDF.</p>
</cfif>
</cfif>

CF thinks the file is a pdf, it reads the file, it thinks the pdf document variable is valid, then when it tries to write, I get an error:


The file or directory (/Library/WebServer/Documents/coldfusion.pdf.PDFDocWrapper@1547134d) specified in the source attribute in the CFPDF tag does not exist.

The error occurred in /Library/WebServer/Documents/test.cfm: line 4

2 : <cfpdf source="filein.pdf" action="read" name="myPDFform"/>
3 : <cfif IsPDFObject(myPDFform)>
4 : <cfpdf source=#myPDFform# action="write" destination = "fileout.pdf">
5 : <cfelse>
6 : <p>This is not a PDF.</p>

Given where CF seems to be generating a temp file I could see this being a problem on my Linux box where cf can’t write to the webroot.  That would not be a problem on my local dev environment though where I can write to the webroot.  On both machines I can successfully access pdf files themselves and write to different files to add watermarks, get and set info, etc.  I just cannot work with the pdf document variable at all.  The last pdf file I tested with here was the CF 8.0.1 release notes from Adobe at around 250k.

When I get a solution to this issue, I’ll post it.  If anyone has any thoughts here I’m all ears.  Hopefully someone can point out that I’m doing something stupid and share a correction.  Otherwise I’ll submit a bug to Adobe.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Slashdot
  • StumbleUpon
  • Technorati
  1. Pope says:

    I know this is pretty old, and you probably already found a solution, but for completeness, and because you asked me to…

    “coldfusion.pdf.PDFDocWrapper@1547134d” says you are indeed working with a pdf object. You are trying to pass that object as a source when the CFPDF tag is looking for a file name, or the name of a valid pdf object. Not the actual pdf object itself.

    Take off the pound signs and wrap it in quotes. Your example then works more or less as a copy action would.

    OR