Get Page Information

Get page information

This example reads the main geometric properties of page 1.

Steps

  1. Create a PdfFileInfo object for the source PDF.
  2. Call getPageWidth, getPageHeight, and getPageRotation for the page you want to inspect.
  3. Use or print the returned values.
  4. Close the PdfFileInfo instance.

Java example

public static void getPageInformation(Path inputFile) {
    PdfFileInfo pdfInfo = new PdfFileInfo(inputFile.toString());
    System.out.println("Page Width: " + pdfInfo.getPageWidth(1));
    System.out.println("Page Height: " + pdfInfo.getPageHeight(1));
    System.out.println("Page Rotation: " + pdfInfo.getPageRotation(1));
    pdfInfo.close();
}