You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Michael Doswald (JIRA)" <ji...@apache.org> on 2016/07/13 15:07:20 UTC

[jira] [Commented] (PDFBOX-3421) Optimize float to string conversion in PDAbstractContentStream

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

Michael Doswald commented on PDFBOX-3421:
-----------------------------------------

Another issue that may be discussed in connection with this is the number of fraction digits used when formatting a real value. Currently the maximum number of fraction digits is set to 10. In the PDF Reference Version 1.7, Appendix C, it states that the number of significant decimal digits of precision in fractional part is (approximate) 5. I think that would be enough. Old versions of Acrobat (before version 6) use fixed point numbers with only 16-bits on either side of the radix point anyways.

> Optimize float to string conversion in PDAbstractContentStream
> --------------------------------------------------------------
>
>                 Key: PDFBOX-3421
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3421
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: PDModel
>    Affects Versions: 2.0.2
>         Environment: Ubuntu 14.04
>            Reporter: Michael Doswald
>            Priority: Trivial
>              Labels: optimization, performance
>         Attachments: PDFBOX-3421_Float_formatting_performance_rev1.patch, pdfbox-performance-floatformat.zip
>
>
> Drawing lines in a PDF (and also other operations) writes the coordinates to the content stream. Currently, the PDAbstractContentStream#writeOperand(float) method uses the NumberFormat class to convert the float values. This is inefficient for multiple reasons:
> * NumberFormat is designed to format numbers locale dependent. That is not needed in this case
> * NumberFormat uses a pattern to format the value which is also not needed in this case
> * The formatting first creates a String object, converts it to a byte array with ASCII encoding and then writes it to the stream. This generates a lot of garbage.
> A different approach to formatting real operands should be used.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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