[
https://issues.apache.org/jira/browse/PDFBOX-6204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18079445#comment-18079445
]
ASF subversion and git services commented on PDFBOX-6204:
---------------------------------------------------------
Commit 1933934 from Tilman Hausherr in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1933934 ]
PDFBOX-6204: don't assign wrong length, as suggested by Stefan Ziegler
> 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: 2.0.36, 3.0.7 PDFBox
> Reporter: Stefan Ziegler
> Priority: Major
> Fix For: 2.0.37, 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]