• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFPDF not working

New Here ,
Jun 16, 2014 Jun 16, 2014

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

Views

766

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Jun 18, 2014 Jun 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.

Votes

Translate

Translate
Community Expert ,
Jun 17, 2014 Jun 17, 2014

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 17, 2014 Jun 17, 2014

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,

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 17, 2014 Jun 17, 2014

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 17, 2014 Jun 17, 2014

Copy link to clipboard

Copied

I did, I watched out for both things

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 18, 2014 Jun 18, 2014

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 18, 2014 Jun 18, 2014

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 18, 2014 Jun 18, 2014

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 18, 2014 Jun 18, 2014

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.

Dropbox - TEST.pdf

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 18, 2014 Jun 18, 2014

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 18, 2014 Jun 18, 2014

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 18, 2014 Jun 18, 2014

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 18, 2014 Jun 18, 2014

Copy link to clipboard

Copied

LATEST

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!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation