画像操作
Contents
[
Hide
]
現在の Java PdfContentEditorExamples クラスは replaceImage(...) を直接サポートしています。
画像の置換
- ソース PDF を
PdfContentEditorファサードにバインドしてください。 - ページ番号、画像インデックス、および置換画像のパスを指定して
replaceImage(...)を呼び出してください。 - 更新された PDF ドキュメントを保存してください。
public static void replaceImage(Path inputFile, Path imageFile, Path outputFile) {
PdfContentEditor editor = new PdfContentEditor();
try {
editor.bindPdf(inputFile.toString());
editor.replaceImage(1, 1, imageFile.toString());
editor.save(outputFile.toString());
} finally {
editor.close();
}
}