[ 
https://issues.apache.org/jira/browse/PDFBOX-1317?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13279662#comment-13279662
 ] 

Manoj Patel commented on PDFBOX-1317:
-------------------------------------

I have corrected annotations in document i.e just reassigned annotations by 
below mentioned function and it's working fine

private static void correctAnnotationInDoc(PDDocument doc) throws Exception{    
                
        List allPages = doc.getDocumentCatalog().getAllPages();
        
        PDAcroForm acroForm = null;
        
        for(int i = 0; i < allPages.size(); i++){  
                PDPage pdPage = (PDPage)allPages.get(i);                
                COSArrayList annotations = 
(COSArrayList)pdPage.getAnnotations();               
                PDDocumentCatalog catalog = doc.getDocumentCatalog();
                
                if(catalog.getAcroForm() != null && acroForm == null){          
                        acroForm = catalog.getAcroForm();                       
                        //System.out.println("Fields:::::" + 
acroForm.getFields());                                             
                }
                
                if(i == 0 && acroForm != null)
                        acroForm.getFields().clear();
                
                Iterator it = annotations.iterator();           
                while(it.hasNext()){                            
                        PDAnnotation widget = (PDAnnotation)it.next();
                        COSDictionary dictionary = 
(COSDictionary)widget.getCOSObject();
                        
                        COSBase parentObj = 
dictionary.getDictionaryObject(COSName.PARENT);
                        if(parentObj == null){
                                dictionary.removeItem(COSName.PARENT);
                        }
                        //System.out.println("Widget::" + 
widget.getAnnotationName());
                        widget.setPage(pdPage);                         
                        
//widget.setAnnotationFlags(PDAnnotationWidget.FLAG_PRINTED);                   
                                
                        acroForm.getFields().add(widget);                       
                
                }
        }
    }

 



                
> PDFBox giving AcroFields size zero for some pdf document.
> ---------------------------------------------------------
>
>                 Key: PDFBOX-1317
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1317
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Manoj Patel
>
> I am working on PDF Form fill utility and found some of pdf return blank 
> acrofield array. 
> Download PDF document from below mentioned link
> https://skydrive.live.com/redir?resid=C420713A859E927D!118&authkey=!AJqh1odSC8MqMrE
> It will give blank list of acrofields.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to