从 PDF 中删除页面
Contents
[
Hide
]
删除 PDF 页面
此 Java 示例从源文档中删除第 2 页和第 4 页。
步骤
- 创建一个
PdfFileEditor实例。 - 构建一个包含要删除的页码的数组。
- 调用
delete使用输入文件、页面数组和输出文件。 - 保存生成的 PDF。
Java 示例
public static void deletePagesFromPdf(Path inputFile, Path outputFile) {
PdfFileEditor pdfEditor = new PdfFileEditor();
pdfEditor.delete(inputFile.toString(), new int[] {2, 4}, outputFile.toString());
}