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 = [None] * 3
17
18pdf_files[0] = r"D:\\Part1.pdf"
19pdf_files[1] = r"D:\\Part2.pdf"
20pdf_files[2] = r"D:\\Part3.pdf"
21
22# Create a single destination file
23pdf_destination = r"D:\\Merged.pdf"
24
25# Perform the PDF merge
26if pdf_utils.merge_pdf_files(pdf_files, pdf_destination):
27 ot.add("Successfully merged PDF files")
28
29else:
30 ot.add("Failed to merge PDF files")