[ 
https://issues.apache.org/jira/browse/PDFBOX-6204?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tilman Hausherr updated PDFBOX-6204:
------------------------------------
    Fix Version/s: 3.0.8 PDFBox
                   4.0.0

> PDType1FontEmbedder sets /Length to uncompressed PFB size
> ---------------------------------------------------------
>
>                 Key: PDFBOX-6204
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-6204
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 3.0.7 PDFBox
>            Reporter: Stefan Ziegler
>            Priority: Major
>             Fix For: 3.0.8 PDFBox, 4.0.0
>
>
> {{PDType1FontEmbedder}} constructs a {{PDStream}} with {{{}FLATE_DECODE{}}}, 
> which correctly sets {{/Length}} to the compressed byte count. It then 
> immediately overwrites that value with {{pfbParser.size()}} — the total 
> *uncompressed* PFB size:
> {code:java}
> // PDType1FontEmbedder.java, ~line 80
> PDStream fontStream = new PDStream(doc, pfbParser.getInputStream(), 
> COSName.FLATE_DECODE);
> fontStream.getCOSObject().setInt("Length", pfbParser.size());   // ← wrong: 
> uncompressed size
> for (int i = 0; i < pfbParser.getLengths().length; i++)
>     fontStream.getCOSObject().setInt("Length" + (i + 1), 
> pfbParser.getLengths()[i]); // ← correct{code}
> Per PDF spec, /Length on a stream must equal the number of bytes of the 
> encoded (post-filter) data.
> The following line should be completely removed:
> {code:java}
> fontStream.getCOSObject().setInt("Length", pfbParser.size());{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to