You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Maruan Sahyoun (JIRA)" <ji...@apache.org> on 2017/02/15 22:50:41 UTC

[jira] [Commented] (PDFBOX-3687) PDFBox not recognizing Auto font size for PDField

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

Maruan Sahyoun commented on PDFBOX-3687:
----------------------------------------

The field "Bureau" appears two times on the form - page 1 and page 3. So there are two annotations associated with it. Now there is a DA entry on the field level with font size 9 and there is a DA entry for the first annotation with font size 0 -> Auto font size. PDFBox only looks at the DA on the field level as there is no DA entry for a widget annotation defined in the PDF spec. So the form is not totally correct if I'm not mistaken.

What we could do is handle it the same way Acrobat does and look if there is a DA entry for the annotation and let that overwrite the DA entry on the field level.

There will be an issue with the form from an end users perspective though: as the first annotation has Auto font size and the second doesn't the text will scale on the first page but not on the third. There the text will be cut off. Not nice IMHO.

BTW ... " set correctly in the PDF " has to be taken with care. There is the PDF spec and there are real world PDFs. Not all real world PDFs are correct with regards to the spec. Acrobat, PDFBox and many other libraries try to do their best to provide workarounds for that. We typically try to match Acrobat - in this case this is the first time I come across such a field definition. 

> 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
(v6.3.15#6346)

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