获取页面信息

获取页面信息

此示例读取第 1 页的主要几何属性。

步骤

  1. 创建一个 PdfFileInfo 源 PDF 的对象。
  2. 调用 getPageWidth, getPageHeight,并且 getPageRotation 对于您想检查的页面。
  3. 使用或打印返回的值。
  4. 关闭 PdfFileInfo 实例。

Java 示例

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();
}