첨부파일 추가
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();
}
}