PDF Merger via Python

Merge PDF documents in a browser without needing Adobe Acrobat or Automation - Python

How to Merge PDF files Using Python for .NET Library

In order to merge PDF file, we’ll use Aspose.PDF for Python API which is a feature-rich, powerful and easy-to-use document manipulation API for python-net platform. Our Python Library can convert a document from any supported download format to any supported save format. Aspose.PDF for Python library provides fairly universal solutions that will help you solve the tasks of converting documents. Aspose.PDF supports the largest number of popular document formats, both for loading and saving. Draw your attention that the current section describes only popular conversions. The current page provides information about converting format to format. However, there are many combinations for converting your files. For a complete list of supported formats, see the section Supported File Formats. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console.

Python Package Manager Console

pip install aspose-pdf

Merge PDF files via Python

You need Aspose.PDF for Python via .NET to try the code in your environment.

  1. Open first document.
  2. Open second document.
  3. Add pages of second document to the first.
  4. Save concatenated output file

Just make sure that you have the following prerequisites.

  • Aspose.PDF for Python via .NET supports any 64-bit or 32-bit operating system where Python >3.5 and <3.12 is installed.
  • If you develop software for Linux, please have a look at additional requirements in Product Documentation

Python - example code to merge PDF files.

    import aspose.pdf as ap

    input_pdf_1 = DIR_INPUT_DOCUMENTS + "concat1.pdf"
    input_pdf_2 = DIR_INPUT_DOCUMENTS + "concat2.pdf"
    output_pdf = DIR_OUTPUT_DOCUMENTS + "merge_pdf_files.pdf"

    # Open first document
    document1 = ap.Document(input_pdf_1)
    # Open second document
    document2 = ap.Document(input_pdf_2)

    # Add pages of second document to the first

    # Save concatenated output file