Get Page Information

Contents
[ ]

The ‘get_page_information’ utility function helps developers understand the structure and layout of PDF pages. Every PDF page may have different dimensions, rotation, and internal offsets, which can impact content placement or automation tasks.

It features retrieving key metadata and layout information for a specific page in a PDF file. The Aspose.PDF Facades API provides details such as page width, height, rotation, and X/Y offsets. This information is essential for tasks like page layout analysis, annotation placement, or automated PDF processing.

  1. Create a PDF facade object.
  2. Retrieve page dimensions and layout.
  3. Print or store the retrieved values.
import aspose.pdf as ap
import aspose.pdf.facades as pdf_facades

import sys
from os import path

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

from config import set_license, initialize_data_dir


def get_page_information(infile):

    # Get and display PDF information
    pdf_info = pdf_facades.PdfFileInfo(infile)
    page_width = pdf_info.get_page_width(1)
    page_height = pdf_info.get_page_height(1)
    page_rotation = pdf_info.get_page_rotation(1)
    page_x_offset = pdf_info.get_page_x_offset(1)
    page_y_offset = pdf_info.get_page_y_offset(1)

    print(f"Page Width: {page_width}")
    print(f"Page Height: {page_height}")
    print(f"Page Rotation: {page_rotation}")