pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: HOW-TO question: getting position of existing signature.
Date Sun, 07 Feb 2016 09:15:26 GMT
Am 07.02.2016 um 09:45 schrieb Tilman Hausherr:
> Am 07.02.2016 um 09:07 schrieb Глеб Г.Г.:
>> Hello PDFbox Users!
>> Is it possible to get visible signature position on page of previously
>> signed PDF file?
>> I am using version 2.0.0 rc3.
>> Best Regards.
>>
>
>
> Go through all fields, find the ones that have the type "Sig", then 
> get the "Rect" element.
>
> To see what I mean, start PDFDebugger, switch to "show internal 
> structure", and enter this:
>
> Root/AcroForm/Fields/[0]/Rect/[0]
>
> This may or may not be a signature field. If it isn't, try the other 
> fields.

Here's some code (error handling omitted):

         PDDocument doc = PDDocument.load(new File("...."));
         List<PDField> fields = 
doc.getDocumentCatalog().getAcroForm().getFields();
         for (PDField field : fields)
         {
             if ("Sig".equals(field.getFieldType()))
             {
System.out.println(field.getWidgets().get(0).getRectangle());
             }
         }
         doc.close();


running it with the file from 
https://issues.apache.org/jira/browse/PDFBOX-2282 brings this output:


[68.52,567.84,245.64,626.04]
[68.88,391.56,246.12,449.76]
[68.88,186.48,246.12,244.68]
[348.72,187.08,525.84,245.28]
[0.0,0.0,456.0,112.0]

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message