Menambahkan lampiran
Contents
[
Hide
]
Menambahkan lampiran dokumen
- Lampirkan PDF sumber ke fasad
PdfContentEditor. - Buka file lampiran sebagai aliran masukan.
- Panggil
addDocumentAttachment(...)dengan stream, nama file, dan deskripsi. - Simpan dokumen PDF yang diperbarui.
public static void addAttachment(Path inputFile, Path attachmentFile, Path outputFile) throws Exception {
PdfContentEditor editor = new PdfContentEditor();
try (InputStream attachmentStream = Files.newInputStream(attachmentFile)) {
editor.bindPdf(inputFile.toString());
editor.addDocumentAttachment(attachmentStream, attachmentFile.getFileName().toString(), "Sample attachment.");
editor.save(outputFile.toString());
} finally {
editor.close();
}
}