0

与えられた例に従うpdfClownと、特定のテキストを強調表示し、それぞれの単語の周りに長方形を描くことができます。

このリアクタブルを後で編集可能にする可能性はありAdobe Acrobatますか?

私の現在のワークフロー (予定):

  1. ドキュメントをインポートする
  2. ハイライトのドキュメントを検索
  3. ハイライトの色を決定する
  4. 長方形の外側の境界の周りに長方形を描画します
  5. 決定された色に応じて、文字を含む別の長方形にコールアウトを追加します

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

    }

}
4

1 に答える 1

0

あなたの主な問題は

Acrobat Reader で以前ハイライト表示されていた単語の周りに四角形をドラッグすることができません (例)。

その理由は、ページ コンテンツに四角形を描画するためです (使用するものは、既存のページにコンテンツを挿入するためのツールPageStamperとして文書化されています)。特に Acrobat Reader に関する限り、ページの内容は固定されています。Acrobat Reader では、注釈の移動のみが可能です。

したがって、ドラッグできる長方形が必要な場合は、長方形の注釈を使用する必要があります。長方形の注釈は次のように作成できます。

new org.pdfclown.documents.interaction.annotations.Rectangle(
  page,
  new Rectangle(50, 370, 100, 30),
  "Text of the Rectangle annotation"
  ).withColor(DeviceRGBColor.get(Color.RED))
   .withBorder(new Border(1, new LineDash(new double[]{5})))
   .withAuthor("Stefano")
   .withSubject("Rectangle")
   .withPopup(new Popup(
     page,
     new Rectangle2D.Double(200, 325, 200, 75),
     "Text of the Popup annotation (this text won't be visible as associating popups to markup annotations overrides the former's properties with the latter's)"
     ));

( AnnotationSample.java )

また、calloutを追加したいと述べています。吹き出し注釈は次のように作成できます。

new StaticNote(
  page,
  new Rectangle(250, 90, 150, 70),
  "Text of the Callout note annotation"
  ).withLine(
     new StaticNote.CalloutLine(
       page,
       new Point(250,125),
       new Point(150,125),
       new Point(100,100)
       )
     )
   .withLineEndStyle(LineEndStyleEnum.OpenArrow)
   .withBorder(new Border(1))
   .withColor(DeviceRGBColor.get(Color.YELLOW));

( AnnotationSample.java )

于 2016-02-10T08:45:48.397 に答える