prawnpdf / pdf-core

Implements low level PDF features for Prawn (experimental)
Other
23 stars 38 forks source link

Limit all PDF decimal numbers to four decimal places #9

Closed practicingruby closed 9 years ago

practicingruby commented 10 years ago

Here's what the "Developing With PDF" book from O'Reilly has to say on this topic:

While the term "real" is used in PDF to represent the object type, the actual implementation of a given viewer might use double, float, or even fixed point numbers. Since the implementations may differ, the number of decimal places of precision may also differ. It is therefore recommended for reliability and also for file size considerations to not write more than four decimal places

I looked this up in the PDF standard and it too said that it's common for "real" numbers to be implemented as fixed point values. In Appendix C, 5 decimal places is recommended as a maximum.

I think we will go with 4 to be a bit more conservative, but if that causes any problems we can try bumping it up to 5. But it's clear that beyond that we can expect trouble... even the standard tells us that.

practicingruby commented 10 years ago

Since some PDF functionality is still directly implemented in Prawn, see the corresponding ticket here: https://github.com/prawnpdf/prawn/issues/780

Ideally we'll move all PDF functionality down into PDF::Core eventually, but it may be some time before that happens.

practicingruby commented 10 years ago

10 is the related pull request for this one.