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());
}
}