Get Page Offset

Get page offset

Use this workflow when you need to understand how page content is positioned relative to the PDF origin.

Steps

  1. Create a PdfFileInfo object for the input PDF.
  2. Call getPageXOffset and getPageYOffset for the target page.
  3. Convert the point values to inches by dividing by 72.0.
  4. Use or print the converted values.
  5. Close the PdfFileInfo instance.

Java example

public static void getPageOffsets(Path inputFile) {
    PdfFileInfo pdfInfo = new PdfFileInfo(inputFile.toString());
    System.out.println("Page X Offset: " + (pdfInfo.getPageXOffset(1) / 72.0) + " inches");
    System.out.println("Page Y Offset: " + (pdfInfo.getPageYOffset(1) / 72.0) + " inches");
    pdfInfo.close();
}