Concatenate Two PDF Files
Contents
[
Hide
]
Combining two PDF files is a common task when consolidating reports, contracts, or forms. Using Aspose.PDF for Python, you can programmatically merge two PDFs into a single document using the concatenate method of the PdfFileEditor class. This ensures that all pages from both files are included in the output PDF while maintaining the original layout, content, and structure.
- Create a PdfFileEditor Object.
- Merge Two PDF Files.
import aspose.pdf as ap
import aspose.pdf.facades as pdf_facades
import sys
from os import path
sys.path.append(path.join(path.dirname(__file__), ".."))
from config import set_license, initialize_data_dir
def concatenate_two_files(files_to_merge, output_file):
# Create a PdfFileEditor object
pdf_editor = pdf_facades.PdfFileEditor()
pdf_editor.concatenate(files_to_merge[0], files_to_merge[1], output_file)