إضافة مرفق
Contents
[
Hide
]
إضافة مرفق مستند
- اربط ملف PDF المصدر بـ
PdfContentEditorالواجهة. - افتح ملف المرفق كدفق إدخال.
- استدعِ
addDocumentAttachment(...)مع الدفق، اسم الملف، والوصف. - احفظ مستند PDF المحدث.
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();
}
}