ColdFusion cfpdf Thumbnail numbering is incorrect

128 Views Asked by At

I am using the cfpdf function in ColdFusion to create a document packet, i.e. merging a range of documents into one PDF file. The merge works correctly and the thumbnail images correctly link to their respective pages. However, the page numbers shown underneath the thumbnail images are incorrect. At some point in the process, the numbering is restarted as can be seen in the image below:

enter image description here

This issue only occurs when the cfpdf function is given a directory to work with, not when the files are specified individually. Due to the potentially large number of files which may be processed, specifying the files individually would be impractical.

I am using ColdFusion 11.

Has anyone else here experienced this issue or has any remedial suggestions?

The code I am using is:

<cfpdf action="merge" 
    directory="C:\temp" <!--- Directory contains multiple PDF files --->
    destination="Packet.pdf"
    order="name" 
    ascending="yes"
    overwrite="yes"
    keepbookmark="yes">
2

There are 2 best solutions below

0
On

There appears to be no way around this issue, so we are going to use a third party solution to merge our PDF documents.

10
On

Try doing what the directory attribute in <cfpdf> is supposed to do:

<cfdirectory
     action="list" directory="C:\temp\"
     type="file" filter="*.pdf" sort="ASC"
     name="filesToMerge"
>

<cfpdf
    action="merge" destination="Packet.pdf"
    overwrite="yes"
    keepbookmark="yes"
>
    <cfloop query="filesToMerge">
        <cfpdfparam source="#filesToMerge.directory#\#filesToMerge.name#"> 
    </cfloop>
</cfpdf>

Does the order in filesToMerge return what you expect?

Now try removing all meta data in case the PDF files had their page number stored:

<cfpdf
    action="optimize" source="Packet.pdf" destination="Packet_noMeta.pdf"
    algo="bilinear" nometadata="true"
>