Wednesday, June 27, 2007

cfpdf - action = merge

 
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>
 

12 comments:

Anonymous said...

awesome post!!! thanks!

Anonymous said...

Is there a way to redo the page numbers in footers (for ex.) after a merge?

Javi said...

Ahamad,

I had commented on another post but I see here you have something on merging. Is it possible to merged several populated dynamic PDF's and not lose the populated data in those PDF's in the final merged file?

At work I'm creating a service to handle this for us. So far its worked great except on the last portion when merging. I'm worried that we can't take our dynamic PDF's built with LiveCycle Designer, populate individual ones and then merge them together still containing that populated data.

Ahamad said...

@Javi,
Please try the following:
1. Fill the forms using cfpdfform.
2. Flatten the filled up forms using cfpdf write, flatten=true.
3. Merge the flattened forms usinf cfpdf merge.

It is difficult to post code in the comments for blogger. I will post a separate blog entry with the source code.

Ahamad said...

I have added a new post and example code, Please check - http://cfpdf.blogspot.com/2008/04/populate-and-merge-multiple-pdf-forms.html

Anonymous said...


viagra [url=http://www.viagracheap.biz]viagra [/url]http://www.viagracheap.biz

Anonymous said...


viagra, [url=http://gearheadrpg.com/wiki/index.php?title=An-Overview-of-the-Impotence-Pill]viagra[/url],

http://gearheadrpg.com/wiki/index.php?title=An-Overview-of-the-Impotence-Pill

viagra, [url=http://manual.eblackcu.net/wiki/index.php?title=Drug-to-Treat-Erectile-Dysfunction]viagra[/url],

http://manual.eblackcu.net/wiki/index.php?title=Drug-to-Treat-Erectile-Dysfunction

viagra, [url=http://www.stanhope.org.uk/uprightman/index.php?title=Drug-to-Treat-Erectile-Dysfunction]viagra[/url],

http://www.stanhope.org.uk/uprightman/index.php?title=Drug-to-Treat-Erectile-Dysfunction

viagra, [url=http://www.jokemusic.jp/index.php?title=Male-Enhancement-Pills---How-Much-Do-You-Really-Know-About-Them?]viagra[/url],

http://www.jokemusic.jp/index.php?title=Male-Enhancement-Pills---How-Much-Do-You-Really-Know-About-Them?

viagra, [url=http://fhcwiki.com/wiki/index.php?title=Buying-Guide-For-Branded-and-Generic-ED-Pills]viagra[/url],

http://fhcwiki.com/wiki/index.php?title=Buying-Guide-For-Branded-and-Generic-ED-Pills

Anonymous said...


buy viagra [url=http://www.viagradealsonline.com] viagra[/url]http://www.viagradealsonline.com
Generic Levitra[url=http://www.genericlevitra.us]Generic Levitra[/url]http://www.genericlevitra.us
Order Viagra[url=http://www.orderviagra.us]Order Viagra[/url]http://www.orderviagra.us
buy cialis [url=http://www.onlinecialis.ws] buy cialis online [/url]http://www.onlinecialis.ws

Anonymous said...


Oxycontin[url=http://www.oxycontindrugstore.com]Oxycontin[/url]http://www.oxycontindrugstore.com
Viagra[url=http://www.viagra-10.us]Viagra[/url]http://www.viagra-10.us
Viagra[url=http://www.viagras.name]Viagra[/url]http://www.viagras.name
Hydrocodone [url=http://www.hydrocodonewithoutprescription.biz] Hydrocodone Without Prescription[/url]http://www.hydrocodonewithoutprescription.biz

Anonymous said...


http://moodle.obu.edu/mahara/view/view.php?id=1092

viagra, [url=http://moodle.mspp.edu/mahara/view/view.php?id=606]viagra[/url],

http://moodle.mspp.edu/mahara/view/view.php?id=606

viagra, [url=http://aluniversity.edu/elearning/blog/index.php?userid=28074]viagra[/url],

http://aluniversity.edu/elearning/blog/index.php?userid=28074

viagra, [url=http://moodle.perelandra.edu/moodle/blog/index.php?postid=51291]viagra[/url],

http://moodle.perelandra.edu/moodle/blog/index.php?postid=51291

viagra, [url=http://ccdb-portal.crbs.ucsd.edu/web/richardsmith/advantages-of-the-blue-pill]viagra[/url],

http://ccdb-portal.crbs.ucsd.edu/web/richardsmith/advantages-of-the-blue-pill


Closeing Spinn ----->

Anonymous said...


http://100.jrn.msu.edu/groups/an-introduction-to-appetite-suppressants/

phentermine, [url=https://testing.moodle.umn.edu/1.9.8/blog/index.php?postid=10412]phentermine[/url],

https://testing.moodle.umn.edu/1.9.8/blog/index.php?postid=10412

phentermine, [url=https://fuji.wcu.edu/groups/wresaworkshopongifted/weblog/92b8f/An_Introduction_To_Appetite_Suppressants.html]phentermine[/url],

https://fuji.wcu.edu/groups/wresaworkshopongifted/weblog/92b8f/An_Introduction_To_Appetite_Suppressants.html

phentermine, [url=http://www2.ku.edu/~lsisync/cgi-bin/wordpress/groups/an-introduction-to-appetite-suppressants/]phentermine[/url],

http://www2.ku.edu/~lsisync/cgi-bin/wordpress/groups/an-introduction-to-appetite-suppressants/

phentermine, [url=http://eport.uaa.alaska.edu/mahara/view/view.php?id=7539]phentermine[/url],

http://eport.uaa.alaska.edu/mahara/view/view.php?id=7539

phentermine, [url=https://www.mac.cs.csi.cuny.edu/groups/csc126/wiki/a893a/An_Introduction_To_Appetite_Suppressants.html]phentermine[/url],

Kamagra 100mg said...

Nice Post Love Reading Its

generic Viagra

silagra pills