Operasi gambar
Contents
[
Hide
]
Java saat ini kelas PdfContentEditorExamples secara langsung mendukung replaceImage(...).
Mengganti gambar
- Ikat PDF sumber ke fasad
PdfContentEditor. - Panggil
replaceImage(...)dengan nomor halaman, indeks gambar, dan jalur gambar pengganti. - Simpan dokumen PDF yang diperbarui.
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();
}
}