Skip to main content
June 27, 2012
Question

Mergin around 40 PDF documents using CFPDF

  • June 27, 2012
  • 3 replies
  • 1728 views

Functionality :

     * Create around 40 PDF's using CFPDFFORM tag (each document is 2 pages only)

     * Merge all the files using CFPDF

Problem:

     * CFPDF  merges the document but the first (or last)  document repeated 40 times !

     * Tried flattening and merge later, flattening removes all the data populated using CFPDFFORM( i dont want flatten the file first of all)

Any help is appreciated

This topic has been closed for replies.

3 replies

Participant
April 8, 2014

I just ran into this same issue. In my case, I was using CFPDFFORM to generate populated copies of an editable PDF form provided by a third party.

When I tried to merge the resulting PDF forms into a single file (for printing), the result was fine; a multi-page PDF form with each page a copy of the original form, each page populated with different data as designed.

However, when I then tried to flatten the merged PDF using CFPDF (action="write" flatten="yes"), that's when the duplication happened. Every resulting page was a duplicate of the last form page in the merged file.

I wasn't sure if it was an issue specific to how the third party PDF form was originally created, or if it was a bug with how CFPDF handles PDF forms, but now I highly suspect it is a CFPDF bug.

In my case, the end goal is to produce a single printable PDF, so my workaround was to write/flatten each individual form page as it created, THEN merge the already flattened results.

Hope that helps. Adobe definitely has some work to do making the CFPDF and CFPDFFORM work the way we all think that it should.

David

BKBK
Community Expert
Community Expert
June 30, 2012

Which cfpdf action attribute did you use? Could it be that you have placed the cfpdf merge-action in your own user-defined loop, and that the loop runs 40 times?

You could use cfpdf's directory-merge action. The following example runs on Windows. It merges all the PDFs in a given directory.

<cfpdf action = "merge"

directory = "C:\Users\BKBK\Desktop\x"

destination = "C:\Users\BKBK\Desktop\x\mergedDoc.pdf"

ascending = "yes"

keepBookmark = "yes"

overwrite = "yes">

done merging

Inspiring
June 28, 2012

It would help to see your code...

July 12, 2012

<cfloop  query="getInfo" >

<!--- populating the PDF form and saving it in folder--->

<cfpdfform

                action="populate"

                source="E:/somedir/INCLUDES/bob.pdf" 

                destination="E://somedir/ATTACHMENTS/subfolder/#YEAR(now())/#bob_#counter#.pdf"

                overwrite = "yes">

            <cfpdfsubform name="form1">

                  <cfpdfformparam name="jacket_no" value="#getInfo.JACKET_NUMBER#">

                  <cfpdfformparam name="REQUISITION_NO" value="#getInfo.RQSTN_NUM#">

                  <cfpdfformparam name="test" value="U.S.  Agency">

                  <cfpdfformparam name="PUBLICATION_TITLE" value="#getInfo.CFR_NAME#">

                  <cfpdfformparam name="QUANTITY_Units_of_Finished_Product" value="#getBookTotals.total#">

                  <cfpdfformparam name="DATE_PREPARED" value="#DateFormat(now(), "MM/DD/YYYY")#">

            </cfpdfsubform>

      </cfpdfform>

    </cfloop>

    <!--- megring the folder --->

     <cfpdf action="merge"

                        destination="E:/somedir/attachments/sf1/bob_#YEAR(now())#.pdf"

            directory ="E:/somedir/attachments/subfolder/#YEAR(now())#" 

            order="name"

            ascending="yes"

            overwrite="yes" >

    </cfpdf>

The issue same file(first or last PDF file) repeats itself in the merged PDF , but individual PDF docuemtns inside the merged direcotry differ in data. not sure what causing it though.

BKBK
Community Expert
Community Expert
July 13, 2012

E://somedir/ATTACHMENTS/subfolder/#YEAR(now())/#bob_#counter#.pdf"

1) Use #YEAR(now())#/ not #YEAR(now())/#

2) The variable counter doesn't seem to vary within the loop. That could lead to duplication.