Java を使用した注釈のインポートとエクスポート
Contents
[
Hide
]
PDF を 1 つから別の PDF へ注釈のコピー
- ソース PDF を開き、ターゲットページを持つ新しい宛先ドキュメントを作成してください。
- 最初のソースページの注釈を列挙し、それぞれを宛先ページに追加してください。
- コピーされた注釈を永続化するには、宛先ドキュメントを保存してください。
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());
}
}