Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

CFPDF problem

Posted on 2011-05-11
22
Medium Priority
?
1,089 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:jdthedj
  • 11
  • 8
  • 3
22 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 35743229
What does the stack trace say? Should be beneath the last error line 223: </CFPDF>
0
 
LVL 3

Author Comment

by:jdthedj
ID: 35743283
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
 
LVL 52

Expert Comment

by:_agx_
ID: 35743562
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 35743575
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
 
LVL 52

Expert Comment

by:_agx_
ID: 35743589
Sorry to comment and run jdthedj. But I have to head out! :/
0
 
LVL 3

Author Comment

by:jdthedj
ID: 35743592
@ _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
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 35743600
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
 
LVL 3

Author Comment

by:jdthedj
ID: 35743616
I'll test that and come back shortly
0
 
LVL 3

Author Comment

by:jdthedj
ID: 35743652
@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
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 35743683
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
 
LVL 3

Author Comment

by:jdthedj
ID: 35743690
I don't think CFFLUSH works with CFPDF?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35744059
@jdthedj

What version of CF are you running?

Also, can you attach the testing pdfs you used?
0
 
LVL 3

Author Comment

by:jdthedj
ID: 35750150
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
 
LVL 52

Expert Comment

by:_agx_
ID: 35756357
Ok, thanks. +I'll give it a whirl when I get near a box w/cf8.
0
 
LVL 3

Author Comment

by:jdthedj
ID: 35780596
@_agx_:
Have you had a chance to test the files?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35780645
No sorry. Turns out I won't have access to a CF8 box this week :( Maybe someone else can try them?
0
 
LVL 3

Author Comment

by:jdthedj
ID: 35780675
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
 
LVL 3

Accepted Solution

by:
jdthedj earned 0 total points
ID: 35797460
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
 
LVL 52

Expert Comment

by:_agx_
ID: 35828909
@jdthedj - Sorry to leave you hanging, but I had an emergency of my own and couldn't get back to this.
0
 
LVL 3

Author Comment

by:jdthedj
ID: 35828916
Thanks _agx_ Hope your emergency wasn't major
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35837059
Fortunately everything's okay now. Thanks.
0
 
LVL 3

Author Closing Comment

by:jdthedj
ID: 35859691
In absence of further comments I am accepting my own comment.  Further testing at work and home seems to confirm my notion.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question