1

この例では:

Document document=new Document();
PdfWriter.getInstance(document,new FileOutputStream("hello.pdf"));
document.open();  
Paragraph paragraph = new Paragraph();
paragraph.add(new Chunk("Hello ");
paragraph.add(new Chunk("world");
paragraph.add(new Chunk(" in");
paragraph.add(new Chunk(" iText 2.7.1");
document.add(paragraph);
document.close(); 

2番目のチャンク「ワールド」のページの絶対位置、幅、高さを取得するにはどうすればよいですか?つまり、ユーザースペースのバウンディングボックスです。

4

1 に答える 1

2

チャンクで提供される汎用タグ機能を使用できます。

    public class PEvents extends PdfPageEventHelper {
      @Override
      public void onGenericTag(PdfWriter w, Document doc, Rectangle r, String tag) {
         if (tag.equals("mytag")) {             
           //here r is the rectangle of "world" chunk
         }
      }
    }
    writer.setPageEvent(new PEvents());
    Chunk world = new Chunk("world");
    world.setGenericTag("mytag");
    paragraph.add(world);
    . . .
于 2012-07-30T09:23:59.743 に答える