获取页面信息
Contents
[
Hide
]
获取页面信息
此示例读取第 1 页的主要几何属性。
步骤
- 创建一个
PdfFileInfo源 PDF 的对象。 - 调用
getPageWidth,getPageHeight,并且getPageRotation对于您想检查的页面。 - 使用或打印返回的值。
- 关闭
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();
}