Merge PDF in Python

High-speed and cross-platform Python library for merging PDF files using Python code

Merge PDF to PDF using Aspose.Slides

Aspose.Slides for Python via .NET is a powerful Python library used to create, convert, merge, and manipulate presentations, PDFs, and other documents. When you merge PDF to PDF, you are effectively combining pages from 2 documents to obtain one PDF file. Aspose.Slides allows you merge PDFs in different ways. You get to merge PDFs with all their shapes, styles, texts, formatting, etc.

Merge PDF to PDF in Python

Using Aspose.Slides for Python via .NET , you can merge PDF files quickly with just a few lines of code

Python code for merging PDF to PDF


import aspose.slides as slides
import aspose.pydrawing as drawing

with slides.Presentation() as pres:
    pres.slides.remove_at(0)
    pres.slides.add_from_pdf("InputPDF1.pdf")
    pres.slides.add_from_pdf("InputPDF2.pdf")

    pres.save("pres.pdf", slides.export.SaveFormat.PDF)

How to merge PDF in Python

  1. Install Aspose.Slides for Python via .NET. See Installation .

  2. Add the library as a reference in your project.

  3. Create an instance of the Presentation class.

  4. Load the PDF files you want to merge.

  5. Save the resulting PDF.

Merge other files

You can also combine files in other formats to get a single file