Skip to main content
Participating Frequently
June 16, 2014
Answered

CFPDF not working

  • June 16, 2014
  • 2 replies
  • 1170 views

Hello, i am trying to use cfpdf and i keep getting the following error:

String index out of range: -1

I don't know why i keep getting that, i'm running coldfusion 11 on debian linux


<CFIF FileExists("#getDirectoryFromPath(getCurrentTemplatePath())#REPORT.pdf")>
<cfpdfform action="read" source="#getDirectoryFromPath(getCurrentTemplatePath())#REPORT.pdf" xmldata="x" result="r">
</cfpdfform>
<cfdump var="#x#" label="XMLData">
<cfdump var="#r#" label="Result"
<CFELSE>
  File doesn't exist
</CFIF>
                  

Thank you

    This topic has been closed for replies.
    Correct answer Dave Ferguson

    I ran the code with the attached pdf.  I get the same error.  I then opened the PDF in Acrobat Pro and Acrobat froze for a few seconds while opening the file.  Once opened I saved the pdf as a new PDF.  This pdf processed just fine.  My guess is that the original PDF is corrupt in some way that is causing the error you are seeing.

    2 replies

    Dave Ferguson
    Dave FergusonCorrect answer
    Participating Frequently
    June 18, 2014

    I ran the code with the attached pdf.  I get the same error.  I then opened the PDF in Acrobat Pro and Acrobat froze for a few seconds while opening the file.  Once opened I saved the pdf as a new PDF.  This pdf processed just fine.  My guess is that the original PDF is corrupt in some way that is causing the error you are seeing.

    Participating Frequently
    June 19, 2014

    Wow, you were right that worked. I wonder why that is, i used livecycle designer es 2 to create it. Maybe there is a certain way that it needs to be saved or exported as. But yeah now it works. Awesome thanks a lot!!!

    BKBK
    Community Expert
    Community Expert
    June 17, 2014

    You can immediately see a syntax error: the line <cfdump var="#r#" label="Result" misses the character > at the end. After correcting this, make sure the file REPORT.pdf is a PDF form and mind case-sensitivity, as you are on Linux.

    Participating Frequently
    June 17, 2014

    You are right the closing bracket would cause an error, but it actually has that in the code I am using, I don't know why when I copied it here it removed that weird. But still having the same issue.

    Thank you,

    BKBK
    Community Expert
    Community Expert
    June 17, 2014

    I mentioned 2 things to watch out for besides the syntax error. Did you look into them?