合并多个 PDF 文件
Contents
[
Hide
]
合并 PDF 文件
Java 示例通过将两个文件传递给基于数组的方式来合并它们。 concatenate 过载。
步骤
- 创建一个
PdfFileEditor实例。 - 构建一个包含输入 PDF 路径的字符串数组。
- 调用
concatenate使用输入数组和输出文件路径。 - 保存合并后的文档。
public static void mergePdfDocuments(Path firstInputFile, Path secondInputFile, Path outputFile) {
PdfFileEditor pdfEditor = new PdfFileEditor();
pdfEditor.concatenate(new String[] {firstInputFile.toString(), secondInputFile.toString()}, outputFile.toString());
}
要合并超过两个文件,请扩展传递给的字符串数组 concatenate。