APS NZ
asked on
CFPDF problem
I have a problem with the CFPDF tag because I am getting unpredictable results. I have a master PDF file with 5 pages in it and I want to split the pages out to other files. Sometimes the file to be added to exists, other times not.
Here is my code which is surrounded with <CFTRY> <CFCATCH>:
<CFIF FileExists("#OriginalFile# ")>
<CFPDF Action="Merge" Destination="#OriginalFile #" Overwrite="Yes">
<CFPDFPARAM Source="#OriginalFile#">
<CFPDFPARAM Source="#Session.RootDir#\ Temporary Scans\#form.FName#" Pages="#MCtr#-#MPages#">
</CFPDF>
<CFELSE>
<CFPDF Action="Merge" Destination="#OriginalFile #" Overwrite="Yes" Source="#Session.RootDir#\ Temporary Scans\#form.FName#" Pages="#MCtr#-#MPages#">
</CFIF>
In testing I start with no existing files to be added to. #Rating# contains a number to be used as the filename. The list is as follows:
168244 (1)
20518 (2)
168244 (3)
20518 (4)
168244 (5)
When I run the code originally it crashes on (2) (4) and (5). If I run the code a second time I get a crash on (3) (4) and (5). A third run will crash on (2) (3) (4) and (5). The error report is attached.
Here is my code which is surrounded with <CFTRY> <CFCATCH>:
<CFIF FileExists("#OriginalFile#
<CFPDF Action="Merge" Destination="#OriginalFile
<CFPDFPARAM Source="#OriginalFile#">
<CFPDFPARAM Source="#Session.RootDir#\
</CFPDF>
<CFELSE>
<CFPDF Action="Merge" Destination="#OriginalFile
</CFIF>
In testing I start with no existing files to be added to. #Rating# contains a number to be used as the filename. The list is as follows:
168244 (1)
20518 (2)
168244 (3)
20518 (4)
168244 (5)
When I run the code originally it crashes on (2) (4) and (5). If I run the code a second time I get a crash on (3) (4) and (5). A third run will crash on (2) (3) (4) and (5). The error report is attached.
What does the stack trace say? Should be beneath the last error line 223: </CFPDF>
ASKER
Thanks for the reply _agx_. Stack trace attached. It appears to be saying it cannot find the source, but when I trap with CFCATCH it will show the correct filename. Also the FileExists line must have found the file? Stack.txt
It appears to be saying it cannot find the source
You mean this part?
java.lang.NullPointerExcep tion
at com.adobe.internal.pdftool kit.pdf.do cument.PDF Document.r equireCata log(Unknown Source)
IIRC that's the just the compiler saying it doesn't know what line number in the internal code the error occurred on.
Are these pdf's confidential/proprietary or are they just samples you can post here?
You mean this part?
java.lang.NullPointerExcep
at com.adobe.internal.pdftool
IIRC that's the just the compiler saying it doesn't know what line number in the internal code the error occurred on.
Are these pdf's confidential/proprietary or are they just samples you can post here?
You are using the same file name in CFPDF merge and CFPDFPARAM Source...
<CFPDF Action="Merge" Destination="#OriginalFile#" Overwrite="Yes">
<CFPDFPARAM Source="#OriginalFile#">
...
what happens if you change the DESTINATION in CFPDF to a NEW PDF file where you want to merge the original file and the form.FNAME ? Also if you are merging in the Original File, do you really need to define it again in CFPDFPARAM Source ?
<CFPDF Action="Merge" Destination="#OriginalFile#" Overwrite="Yes">
<CFPDFPARAM Source="#OriginalFile#">
...
what happens if you change the DESTINATION in CFPDF to a NEW PDF file where you want to merge the original file and the form.FNAME ? Also if you are merging in the Original File, do you really need to define it again in CFPDFPARAM Source ?
<CFIF FileExists("#OriginalFile#")>
<CFPDF Action="Merge" Destination="#OriginalFile#" Overwrite="Yes">
<CFPDFPARAM Source="#Session.RootDir#\Temporary Scans\#form.FName#" Pages="#MCtr#-#MPages#">
</CFPDF>
<CFELSE>
<CFPDF Action="Merge" Destination="#OriginalFile#" Overwrite="Yes" Source="#Session.RootDir#\Temporary Scans\#form.FName#" Pages="#MCtr#-#MPages#">
</CFIF>
Sorry to comment and run jdthedj. But I have to head out! :/
ASKER
@ _agx_
Unfortunately the files are confidential, but I can probably scan in some gobbledygook pages. We are a recruitment company and applicants send us CVs etc which we scan to file. I create one big pdf with all the pages for the week in it and a table holds the number of pages per scan so I am trying to get CFPDF to break up the main file and merge it with any file the applicant already has on file - or if none exists, create it.
@brijeshchauhan:
If I don't specify the source again in the CFPDFPARAM it overwrites the original file.
Unfortunately the files are confidential, but I can probably scan in some gobbledygook pages. We are a recruitment company and applicants send us CVs etc which we scan to file. I create one big pdf with all the pages for the week in it and a table holds the number of pages per scan so I am trying to get CFPDF to break up the main file and merge it with any file the applicant already has on file - or if none exists, create it.
@brijeshchauhan:
If I don't specify the source again in the CFPDFPARAM it overwrites the original file.
If I don't specify the source again in the CFPDFPARAM it overwrites the original file. , so that means it works by overwritting the original file, so can you try merging them in a NEW FILE instead of the original file ?
ASKER
I'll test that and come back shortly
ASKER
@brijeshchauhan:
I have tried your suggestion, creating a new file each time, then using CFFILE to delete the original and rename the new file to the original file name. I still have the same error.
@_agx_:
I have scanned in fresh pages for testing with just a number on the page and the problem still persists. I have also tried the merge in Acrobat and it works fine there.
I'm wondering if something needs *flushing* somehow between merges?
I have tried your suggestion, creating a new file each time, then using CFFILE to delete the original and rename the new file to the original file name. I still have the same error.
@_agx_:
I have scanned in fresh pages for testing with just a number on the page and the problem still persists. I have also tried the merge in Acrobat and it works fine there.
I'm wondering if something needs *flushing* somehow between merges?
I tried your code on my local system and it works correctly... flushing might be a good idea, as there are no issues that I could see running the above code locally...
ASKER
I don't think CFFLUSH works with CFPDF?
@jdthedj
What version of CF are you running?
Also, can you attach the testing pdfs you used?
What version of CF are you running?
Also, can you attach the testing pdfs you used?
ASKER
We are running CF8. I have attached the master file used for testing and the file for 168244 which is the only file created by run #1 and has two pages instead of the expected 3.
Curiously run #2 will create 20518 with one page in it and 168244 will now have 3 pages. Master.pdf 168244-.pdf
Curiously run #2 will create 20518 with one page in it and 168244 will now have 3 pages. Master.pdf 168244-.pdf
Ok, thanks. +I'll give it a whirl when I get near a box w/cf8.
ASKER
@_agx_:
Have you had a chance to test the files?
Have you had a chance to test the files?
No sorry. Turns out I won't have access to a CF8 box this week :( Maybe someone else can try them?
ASKER
Thanks _agx_ I'm really hoping it can be resolved - our whole document management relies on the scans, and I don't want to have to start again.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@jdthedj - Sorry to leave you hanging, but I had an emergency of my own and couldn't get back to this.
ASKER
Thanks _agx_ Hope your emergency wasn't major
Fortunately everything's okay now. Thanks.
ASKER
In absence of further comments I am accepting my own comment. Further testing at work and home seems to confirm my notion.