pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Manfred Cuntz" <manfred.cu...@gmx.de>
Subject How can I get the absolute position of a form field?
Date Wed, 17 Jul 2013 06:27:47 GMT

Hi Eric,

unfortunately I have deleted the mail and so I cannot answer in the thread. 

But here is your example:

   public void printFieldPos(PDDocument pdfDocument, String fieldName) {
        try {
            PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
            PDAcroForm acroForm = docCatalog.getAcroForm();
            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();
                System.out.println(f.getPartialName() + "   " + llx + "/" + lly);

            }
        } catch (IOException ex) {
            Logger.getLogger(SetField.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

Hope it will help you.

Regards,
Manfred

Mime
View raw message