[
https://issues.apache.org/jira/browse/PDFBOX-6204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18079326#comment-18079326
]
Tilman Hausherr commented on PDFBOX-6204:
-----------------------------------------
Nice find. This is over 10 years old. The line was legit before PDFBOX-2893,
and wasn't deleted when compression was introduced.
> 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
>
> {{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]