You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Ken Bowen <kb...@als.com> on 2010/05/23 15:09:47 UTC

Re: [Solved] Determining page number for each field

I developed one solution, inspired by the AddMessageToEachPage example.
For those interested, here is an outline sketch:

     extractFields(PDDocument pdfDocument)
     {
       List allPages = pdfDocument.getDocumentCatalog().getAllPages();
       for( int i=0; i<allPages.size(); i++ ) {
	.... keep track of page # i below....
         xtrPageFields( (PDPage)allPages.get(i) );
       }
       pdfDocument.close();
     }

     xtrPageFields(PDPage page)
     {
       Iterator pannotsit = page.getAnnotations().iterator();
       while (pannotsit.hasNext()){
         Object oo = pannotsit.next();
         if (oo instanceof PDAnnotationWidget){
             PDAnnotationWidget aW = (PDAnnotationWidget)oo;
         ...extract info from  aW.getDictionary();
       }
     }

Regards,
Ken Bowen