2016-04-22 26 views
0

PDFBox 2.0.0でフィールドの位置を取得する方法は? Pdfbox 1.8.11とで それはこのように私の作品:pdfbox PDFBox 2.0.0フィールドの位置を取得

  String formTemplate = "Template.pdf"; 
      PDDocument pdfDocument = PDDocument.load(new File(formTemplate)); 
      PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog(); 
      PDAcroForm acroForm = docCatalog.getAcroForm(); 
      String fieldName = "Name"; 
      PDField f = acroForm.getField(fieldName); 
      if (f != null) { 
       PDRectangle r = f.getWidget().getRectangle(); 
       float llx = r.getLowerLeftX(); 
       float lly = r.getLowerLeftY(); 
       float urx = r.getUpperRightX(); 
       float ury = r.getUpperRightY(); 

さて、f.getWidget()はもう動作してはいけない。..

おかげ ロン

答えて

0

使用

f.getWidgets().get(0) 

フィールドの最初のウィジェットを取得します。ほとんどの場合、1つしか存在しません。フォームフィールドが「ミラーリング」されている場合(たとえば、一度名前を入力すると複雑なフォームの複数のページに表示されるなど)、いくつかのことがあります。

関連する問題