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. Error Message
LVL 3
jdthedjAsked:
Who is Participating?
 
jdthedjAuthor Commented:
In frustration I installed the Developer Edition of CF on my computer at home and did some testing.  It worked without the problems I have been having at work.

At work we have been displaced because of a major earthquake and I am working from a private home in the suburbs which serves as our office.  We are at the far end of the street, and I have discovered that the broadband connection is only running at 128kbits which is not enough to sustain a steady connection when a lot of data is put through it.

I believe *drop-outs* while merging the pdfs is probably what has caused the problem.
0
 
_agx_Commented:
What does the stack trace say? Should be beneath the last error line 223: </CFPDF>
0
 
jdthedjAuthor Commented:
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
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
_agx_Commented:
It appears to be saying it cannot find the source

You mean this part?
java.lang.NullPointerException
      at com.adobe.internal.pdftoolkit.pdf.document.PDFDocument.requireCatalog(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?

0
 
Brijesh ChauhanStaff IT EngineerCommented:
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 ?

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

Open in new window






0
 
_agx_Commented:
Sorry to comment and run jdthedj. But I have to head out! :/
0
 
jdthedjAuthor Commented:
@ _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.
0
 
Brijesh ChauhanStaff IT EngineerCommented:
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 ?
0
 
jdthedjAuthor Commented:
I'll test that and come back shortly
0
 
jdthedjAuthor Commented:
@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?
0
 
Brijesh ChauhanStaff IT EngineerCommented:
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...
0
 
jdthedjAuthor Commented:
I don't think CFFLUSH works with CFPDF?
0
 
_agx_Commented:
@jdthedj

What version of CF are you running?

Also, can you attach the testing pdfs you used?
0
 
jdthedjAuthor Commented:
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
0
 
_agx_Commented:
Ok, thanks. +I'll give it a whirl when I get near a box w/cf8.
0
 
jdthedjAuthor Commented:
@_agx_:
Have you had a chance to test the files?
0
 
_agx_Commented:
No sorry. Turns out I won't have access to a CF8 box this week :( Maybe someone else can try them?
0
 
jdthedjAuthor Commented:
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.
0
 
_agx_Commented:
@jdthedj - Sorry to leave you hanging, but I had an emergency of my own and couldn't get back to this.
0
 
jdthedjAuthor Commented:
Thanks _agx_ Hope your emergency wasn't major
0
 
_agx_Commented:
Fortunately everything's okay now. Thanks.
0
 
jdthedjAuthor Commented:
In absence of further comments I am accepting my own comment.  Further testing at work and home seems to confirm my notion.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.