与えられた例に従うpdfClown
と、特定のテキストを強調表示し、それぞれの単語の周りに長方形を描くことができます。
このリアクタブルを後で編集可能にする可能性はありAdobe Acrobat
ますか?
私の現在のワークフロー (予定):
- ドキュメントをインポートする
- ハイライトのドキュメントを検索
- ハイライトの色を決定する
- 長方形の外側の境界の周りに長方形を描画します
- 決定された色に応じて、文字を含む別の長方形にコールアウトを追加します
Acrobat Reader
私が見る限り、以前に強調表示された単語の周りに四角形をドラッグすることはできません。pdfClown の Web ページから提供された例を使用して、すべての文字の周りに反応角を描画しました。
考慮し忘れたことはありますか?
File inFile = null;
String inFilePath = "/path/to/inputFile/input_highlight.pdf";
String outDirPath = "/tmp";
try {
inFile = new File(inFilePath);
} catch (Exception e) {
throw new RuntimeException(inFilePath + " file access error.", e);
}
Document document = inFile.getDocument();
Pages pages = document.getPages();
PageStamper stamper = new PageStamper();
for (Page page : pages) {
stamper.setPage(page);
PageAnnotations annotations = page.getAnnotations();
for (Annotation annotation : annotations) {
if (annotation.getColor() == null) {
continue;
}
Rectangle2D textStringBox = annotation.getBox();
PrimitiveComposer composer = stamper.getBackground();
composer.setStrokeColor(DeviceRGBColor.Black);
textStringBox.setRect(annotation.getBox().getX(), annotation.getBox().getY(), annotation.getBox().getWidth(), annotation.getBox().getHeight());
composer.drawRectangle(textStringBox);
composer.stroke();
composer.beginLocalState();
composer.setStrokeColor(DeviceRGBColor.Black);
composer.end();
stamper.flush();
System.out.println("Text: " + annotation.getText());
System.out.println("Color: " + annotation.getColor());
System.out.println("Coordinates: " + annotation.getBox().toString());
annotation.setColor(DeviceRGBColor.White);
}
}