Move Pages to PDF via Python

Move Pages in PDF document. Use Aspose.PDF for Python for .NET to modify PDF files programmatically

How to Move pages to PDF Using Python

In order to move page in PDF file, we’ll use Aspose.PDF for .NET API which is a feature-rich, powerful and easy to use document manipulation API for python-net platform. 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

Move Page to PDF via Python


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

  1. Create a Document object with the input PDF file.
  2. Get Page from the the PageCollection collection’s.
  3. Save the output PDF using the Save method.
  4. Add page to the destination document. Save output file.
  5. Delete page in source document.
  6. Save the source PDF using the Save method.

Moving a Page from one PDF Document to Another

import aspose.pdf as ap

srcDocument = ap.Document(src_file_name)
dstDocument = ap.Document(dst_File_name)
page = srcDocument.pages[2]
dstDocument.pages.add(page)
# Save output file
dstDocument.save(dst_File_name_new)
srcDocument.pages.delete(2)
srcDocument.save(src_file_name_new)