Maruan Sahyoun commented on PDFBOX-3687:

[~scoldwell] I'm glad that you found a workaround for you. As I've pointed out 
I'm interested in getting the support in the same way Acrobat handles that. 
Conceptually it's clear what needs to be changed but it takes a little more 
effort as the code is written under the assumption that the DA is on the field 
level only and the DA is stored in a private class member and reused. So there 
are several changes which need to be done and it's not the easiest code to work 
with as this has grown over several years (I have to say that I was part of 
making it even messier). Ideally it needs a rewrite but thats for later. So I 
try to get the changes in but it will be some more days until that's done. Hope 
you can be patient. 

> PDFBox not recognizing Auto font size for PDField
> -------------------------------------------------
>                 Key: PDFBOX-3687
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3687
>             Project: PDFBox
>          Issue Type: Bug
>          Components: AcroForm
>    Affects Versions: 2.0.4
>            Reporter: Scott Coldwell
>         Attachments: SF1152.pdf, TestSF1152-LL.pdf
> See the attached file "SF1152.pdf" and locate the "Bureau" field.  If you 
> open this document in Acrobat the font size shows as Auto and functions as 
> such in Acrobat/Acrobat Reader.  However, PDFBox thinks the font size is set 
> to 9.  I confirmed this in both PDFDebugger and in our rendering code.
> The second attachment "TestSF1152-LL.pdf" shows the behavior from PDFBox not 
> picking up the correct Auto font size.  The value is truncated unless you 
> click inside the field or delete the value and replace it.
> The following code shows the problem:
> {code}
>             final PDDocument document = 
> PDDocument.load(ClassLoader.getSystemResourceAsStream("SF1152.pdf"));
>             final PDAcroForm form = 
> document.getDocumentCatalog().getAcroForm();
>             final PDTextField field = (PDTextField)form.getField("Bureau");
>             final COSDictionary dict = field.getCOSObject();
>             String defaultAppearance = 
> ((COSString)dict.getDictionaryObject(COSName.DA)).getString();
>             System.out.println(defaultAppearance);
> {code}
> results in:
> {code}
> /Helv 9 Tf 0 0 0.5 rg
> {code}
> If I manually set the font size to auto using:
> {code}
> dict.setString(COSName.DA, "/Helv 0 Tf 0 0 0.5 rg");
> {code}
> the PDF renders correctly.
> But we shouldn't have to manipulate font sizes in code when it's set 
> correctly in the PDF.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to