Split PDF from Beginning
Contents
[
Hide
]
Splitting PDFs from the beginning is useful when you need the first few pages of a document as a separate file. Using Aspose.PDF for Python, the split_from_first method in the PdfFileEditor class allows you to extract a defined number of pages starting from page one. This feature is ideal for generating excerpts, previews, or smaller sections of a larger PDF without manually editing the original file.
- Create a PdfFileEditor Object.
- Split PDF from the First Page.
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 from Beginning
def split_pdf_from_beginning(input_pdf_path, output_pdf_path):
pdf_file_editor = pdf_facades.PdfFileEditor()
pdf_file_editor.split_from_first(input_pdf_path, 3, output_pdf_path)