Copy link to clipboard
Copied
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
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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,
Copy link to clipboard
Copied
I mentioned 2 things to watch out for besides the syntax error. Did you look into them?
Copy link to clipboard
Copied
I did, I watched out for both things
Copy link to clipboard
Copied
To rule out the URL, run the following version of the code in the same directory as the PDF file:
<cfoutput>#getDirectoryFromPath(getCurrentTemplatePath())#</cfoutput><br>
<cfpdfform action="read" source="REPORT.pdf" xmldata="x" result="r">
</cfpdfform>
<cfdump var="#x#" label="XMLData">
<cfdump var="#r#" label="Result">
How does the path look like? Where there dumps as expected?
Copy link to clipboard
Copied
I just tried that and the path looks fine its:
/var/www/www.test.com/
But i still get the same error, i also tried the overwrite="yes" and that didn't work. Could it be possibly a bug in coldfusion 11?
Copy link to clipboard
Copied
Let us then get back to the original code. What happens when you test with a path that contains no dots?
Copy link to clipboard
Copied
I just tested that and same thing. If you want to try and test you download the pdf i have uploaded here and see how simple the pdf is. Maybe you can get it to work with this pdf or figure out whats wrong with it.
Copy link to clipboard
Copied
I have tested with your file. I, too, got the error message "String index out of range: -1".
However, from what I can see, the test file is not a PDF form. Test your code with this example of a PDF form, and you will see that it works.
Copy link to clipboard
Copied
Yet another suggestion: add the attribute overwrite="yes" to the cfpdfform tag. There was an old cfpdfform bug report on that.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!!!