Merging PDF Documents

Merging PDF Documents
 1# This example shows how to use IPDFUtilities to merge 3 existing PDF files
 2# into a single PDF file
 3
 4# Create a local variable for the output toolbox
 5ot = impact.gui.output_toolbox
 6
 7# Clear the output toolbox
 8ot.clear()
 9
10# Create the IPDFUtilities object
11pdf_utils = impact.creator.pdf_utilities()
12
13ot.add("PDF Library version: " + str(pdf_utils.library_version.as_string))
14
15# Create an array containing the 3 files to merge
16pdf_files = [r"D:\Part1.pdf", r"D:\Part2.pdf", r"D:\Part3.pdf"]
17
18# Create a single destination file
19pdf_destination = r"D:\Merged.pdf"
20
21# Perform the PDF merge
22if pdf_utils.merge_pdf_files(pdf_files, pdf_destination):
23    ot.add("Successfully merged PDF files")
24
25else:
26    ot.add("Failed to merge PDF files")