Java를 사용하여 주석 가져오기 및 내보내기
Contents
[
Hide
]
한 PDF에서 다른 PDF로 주석 복사
- 원본 PDF
Document를 여세요. - 대상
Document에Page를 추가하세요. - 대상
Page에 각Annotation을 추가하세요. - 대상 페이지의
Annotation항목을 읽거나 반복하세요. - 업데이트된 PDF
Document를 저장하세요. - 첫 번째 원본 페이지에
Annotation항목을 열거하고 각 항목을 대상 페이지에 추가하세요.
public static void importExport(Path inputFile, Path outputFile) {
try (Document sourceDocument = new Document(inputFile.toString());
Document destinationDocument = new Document()) {
Page page = destinationDocument.getPages().add();
for (Annotation annotation : sourceDocument.getPages().get_Item(1).getAnnotations()) {
page.getAnnotations().add(annotation, true);
}
destinationDocument.save(outputFile.toString());
}
}