Split PDF to End

Contents
[ ]

Splitting a PDF from a specific page to the end is useful when you need the latter portion of a document as a separate file. Using Aspose.PDF for Python, the split_to_end method of the PdfFileEditor class allows you to extract pages starting from any page number to the last page of the document. This is ideal for creating excerpts, extracting chapters, or processing parts of a large PDF without manually editing it.

  1. Create a PdfFileEditor Object.
  2. Split PDF from a Specific Page to the End.
from io import FileIO
import sys
from os import path
import aspose.pdf as ap
import aspose.pdf.facades as pdf_facades

sys.path.append(path.join(path.dirname(__file__), ".."))

from config import set_license, initialize_data_dir


# Split PDF to End
def split_pdf_to_end(input_pdf_path, output_pdf_path):
    pdf_file_editor = pdf_facades.PdfFileEditor()
    pdf_file_editor.split_to_end(input_pdf_path, 2, output_pdf_path)