Hi,
I thought I did post some usage examples for the cfpdf tag.
Suppose I have a pdf file of 100 pages, and I want only the selected pages in a separate pdf.
I want only the 7, 10, 15, 20, 25, 40 pages, here is how to acheive this.
<cfset sourcefile = ExpandPath('inputfiles\merge_test1.pdf')>
<cfset destinationfile= ExpandPath('results\merge_result1.pdf')>
<cfpdf action=merge source="#sourcefile#" Pages="7, 10, 15, 20, 25, 40" destination="#destinationfile#" overwrite="true">
Now suppose I want just the first 3 chapters of the entire pdf file, I can specify the page numbers in a block.
Assuming that the first 3 chapters are in the first 30 pages, here is how to acheive that.
<cfpdf action=merge source="#sourcefile#" Pages="1-30" destination="#destinationfile#" overwrite="true">
Supposedly, I wanted just the first chapter(10 Pages) and the 5th Chapter(50-60 Pages)...
<cfpdf action=merge source="#sourcefile#" Pages="1-10, 50-60" destination="#destinationfile#" overwrite="true">
In case you wanted some specific pages along with a block of pages to be merged...
<cfpdf action=merge source="#sourcefile#" Pages="1-10, 21, 31, 41, 50-60" destination="#destinationfile#" overwrite="true">
Now, if your source file is password protected, you can provide the password in the cfpdf tag.
<cfpdf action=merge source="#sourcefile#" Pages="5, 9, 16, 18" password="mypwd" destination="#destinationfile#" overwrite="true">
If we have a set of pdf files in a directory and we want to merge all of the pdf files into a single one,
<cfset sourcedir = ExpandPath('inputfiles\mergetest-dir')>
<cfset destinationfile = ExpandPath('results\merge_result_dir.pdf')>
<cfpdf action=merge directory="#sourcedir#" destination="#destinationfile#" overwrite="true">
In the above action, the files might be merged in any order, suppose I wanted it to merge by the name of the file,
<cfpdf action=merge directory="#sourcedir#" destination="#destinationfile#" order="name" overwrite="true">
And another attribute to help you sort in the way you want(asc or desc)
<cfpdf action=merge directory="#sourcedir#" destination="#destinationfile#" order="name" ascending="false" overwrite="true">
<cfpdf action=merge directory="#sourcedir#" destination="#destinationfile#" order="name" ascending="true" overwrite="true">
We can also have the merged pdf as a variable
<cfpdf action=merge source="#sourcefile#" Pages="7, 10, 11" name="pagedata">
We can perform actions on the variable 'pagedata'
<cfpdf action=getinfo source="pagedata" name="myVar">
<cfoutput>The total number of pages = #myVar.TotalPages#</cfoutput><br><br>
If you are merging a set of pdf files/pages, and you want to keep your bookmark,
<cfpdf action=merge source="#sourcefile#" Pages="7, 10, 11" destination="#destinationfile#" overwrite="true" keepbookmark="true">
Merging diff pages from different pdf's
Now you need to merge a set of pages from different pdf files,
<cfset sourcefile1 = ExpandPath('inputfiles\test1.pdf')>
<cfset sourcefile2 = ExpandPath('inputfiles\test2.pdf')>
<cfset sourcefile3 = ExpandPath('inputfiles\test3.pdf')>
<cfset destinationfile = ExpandPath('results\result1.pdf')>
<cfpdf action="merge" destination="#destinationfile#" overwrite="true">
<cfpdfparam source="#sourcefile1#" pages="1-3, 5">
<cfpdfparam source="#sourcefile2#"><!--- entire pdf here --->
<cfpdfparam source="#sourcefile3#" pages="2" password="cfpdfparam_test3" >
</cfpdf>