I am trying to use cfpdf
and keep getting the following error:
String index out of range: -1
I don't understand why. 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>
Exact error:
String index out of range: -1
The error occurred in /var/www/www.test.com/test.cfm: line 2
1 : <CFIF FileExists("#getDirectoryFromPath(getCurrentTemplatePath())#REPORT.pdf")>
2 : <cfpdfform
action="read"
source="#getDirectoryFromPath(getCurrentTemplatePath())#REPORT.pdf"
xmldata="x" result="r">
3 : </cfpdfform>
4 : <cfdump var="#x#" label="XMLData">
I have had similar issues in the past. The problem has been using non Adobe programs to create the pdf - making a pdf form in Libreoffice, for example, can cause this issue. I assume some internal formatting in the file that CF is looking for is missing.
You can try opening in Acrobat and resaving it.