ActivePDF
Shopping Cart My Account Help Contact Us
Request a Call
Search
Products Solutions Support Downloads Corporate
Submit an Issue
Knowledge Base
Server Product Support
Examples & How-Tos
Support Options
Support Policies
Annual Subscription
Extensions
Documentation
Resource Links
   
 
 
 
 

HomeSupportKnowledge Base
 
activePDF KB #10678 - Merge multiple PDFs into one
activePDF KB #10678 - Merge multiple PDFs into one
Information: Example Printer Version | Return to Search
Merge multiple PDFs into one
 
Product Version Service Pack Code Samples  
Toolkit Std
Toolkit Pro
3.5.2
4.0
4.0 SR1
SP6
VBS
ASP
CF
PHP
 
Description
 
The following ColdFusion® download provides an example of how to use the MergeFile method to combine multiple PDFs into one output PDF.

NOTE: This example is available in other codes. Choose from the Code Samples list above to display the download link for the example in the appropriate code for your environment.

These files are required:
  • Cover.PDF - The first input PDF.
  • Document.PDF - The second input PDF.
  • MergeFile.cfm - Code detail provided below.
Click here to download this example for ColdFusion® (includes required files):
<!--- Variables --->
    <!--- Template and Output files --->
    <CFSET varOutputFile = ExpandPath("output.pdf")>
    <CFSET varMergeFile1 = ExpandPath("cover.pdf")>
    <CFSET varMergeFile2 = ExpandPath("document.pdf")>

<!--- Instantiate Object --->
<CFOBJECT ACTION="Create"
    TYPE="COM"
    CLASS=APToolkit.Object
    NAME="TK">

<!--- OpenOutputFile --->
<CFSET varReturn = TK.OpenOutputFile(varOutputFile)>
<CFIF varReturn gt 0 OR varReturn lt 0>
    <CFOUTPUT>#Error("OpenOutputFile")#</CFOUTPUT>
</CFIF>

<!--- Merge the files --->
<CFSET varReturn = TK.MergeFile(varMergeFile1, 0, 0)>
<CFIF varReturn lt 1>
    <CFOUTPUT>#Error("MergeFile")#</CFOUTPUT>
</CFIF>

<CFSET varReturn = TK.MergeFile(varMergeFile2, 0, 0)>
<CFIF varReturn lt 1>
    <CFOUTPUT>#Error("MergeFile")#</CFOUTPUT>
</CFIF>

<!--- CloseOutputFile --->
<CSET TK.CloseOutputFile>

<!--- Clear Object --->
<CFSET ReleaseComObject(TK)>

<!--- Done --->
<CFOUTPUT>Success!</CFOUTPUT>

<!--- Error Handling --->
<CFFUNCTION name="Error">
    <CFARGUMENT name="method" required="Yes">
    <CFOUTPUT>
    '#method#' failed with a '#varReturn#'<br>
    <a href='http://www.activepdf.com/support/kb/?id=10670&tk=ts'>
    TK Return Codes</a>
    </CFOUTPUT>
    <CFSET ReleaseComObject(TK)>
    <CFABORT>
</CFFUNCTION>
 
Keywords
 
duplicate, merge, combine, fit, together, create, generate, pdf, files, document, add, how, to, mergefile, merge, php, hypertext, preprocessor, toolkit, using, use, one, many, others, only, asp, cfm, cf, coldfusion, cold, fusion, VBS, VBScript, vb, script, example, create, from, html, text, method, property
 
Last Updated 2008-01-17 Printer Version | Return to Search
 
Knowledge Base Article Feedback*
*KB article feedback ONLY (submit support issues here)
Quality of this article?
  Poor Excellent 
1 2 3 4 5 6 7 8 9 10
Is this article helpful? Yes       No       Maybe
Comments (Optional)
Email Address (Optional)
Please enter the word "PDF"
(without quotes)
 
The information in this article is for the use of activePDF Customers and Evaluation Users Only. No part of this document may be transmitted or reproduced without the express written consent of activePDF.

Copyright © 2005, activePDF, Inc. All Rights Reserved
2003 activePDF Site Map Feedback Privacy Policy Legal