画像操作

Contents
[ ]

現在の Java PdfContentEditorExamples クラスは replaceImage(...) を直接サポートしています。

画像の置換

  1. ソース PDF を PdfContentEditor ファサードにバインドしてください。
  2. ページ番号、画像インデックス、および置換画像のパスを指定して replaceImage(...) を呼び出してください。
  3. 更新された 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();
    }
}