You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2017/06/09 16:18:18 UTC

[jira] [Comment Edited] (PDFBOX-3824) Optimize truetype font embedder

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

Tilman Hausherr edited comment on PDFBOX-3824 at 6/9/17 4:17 PM:
-----------------------------------------------------------------

Thanks for your code!

The profiler pointed me to a close(), which did a compress and was called from the TrueTypeEmbedder constructor... The whole (!) font is written into the /FontFile2 stream before being replaced by the subsetted font when saving. This was used for the "old" embedding but is irrelevant for the subset embedding.

After fixing this pdfbox is much faster, even faster than itext 2.1.7 although slower than the current itext version (5.5.11).

There's more to do:
- the other constructor has the same problem
- {{stream.toByteArray().length}} costs some time and memory, the length should be retrieved from ttf
- embedding permission isn't checked in the other constructor
- I found that the bug from PDFBOX-3337 is still there, when repeatably loading a ttf from a file


was (Author: tilman):
Thanks for your code!

The profiler pointed me to a close(), which did a compress and was called from the TrueTypeEmbedder constructor... The whole (!) font is written into the /FontFile2 stream before being replaced by the subsetted font when saving. This was used for the "old" embedding but is irrelevant for the subset embedding.

After fixing this pdfbox is much faster, even faster than itext 2.1.7 although slower than the current itext version.

There's more to do:
- the other constructor has the same problem
- {{stream.toByteArray().length}} costs some time and memory, the length should be retrieved from ttf
- embedding permission isn't checked in the other constructor
- I found that the bug from PDFBOX-3337 is still there in the other constructor


> Optimize truetype font embedder
> -------------------------------
>
>                 Key: PDFBOX-3824
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3824
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: PDModel
>    Affects Versions: 2.0.6
>            Reporter: Tilman Hausherr
>            Assignee: Tilman Hausherr
>              Labels: optimization
>             Fix For: 2.0.7, 3.0.0
>
>         Attachments: Main.java, pom.xml
>
>
> From [~Uwe Möser] in the user mailing list:
> {quote}
> I made a small project which creates 32 pdfs with PDFBox and iText. The output is:
> Time elapsed PDFBox: 2521 msec. (2305msec loading)
> Time elapsed iText: 661 msec.
> It is possible to improve the load function?
> It is possible to create a template document before the loop?
> Tested with PDFBox 2.0.6 and iText 2.1.7.
> {quote}



--
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