Q: I noticed that the content stream PDFTron outputs only contains
coordinates up to 3 decimal places. I also noticed that an output
transformation matrix can contain up to 5 decimal places. The PDF
spec notes that real numbers are accurate to approximately 5 decimal
places (single floating point precision). Is there a way to increase
the precision of the numbers being output?
A: According to the PDF specification, real numbers should have 5
digits of precision (not decimal places).
So, if you have a number such as 0.0000018298111 it will be written as
Although PDFNet SDK can properly parse and write real numbers, it also
allows users to override the default PDFNet number parsing/writing
function (see pdftron::SDF::Number::WriteProc/ReadProc). Please note
that this functionality is only available in the C++ version of the
Q: I may have misinterpreted the PDF Spec. Appendix C notes that real
numbers have "5: Number of significant decimal digits of precision in
_fractional part (approximate)_." (emphasis mine). I read this to
mean that the fractional part will contain 5 decimal digits of
precision, but now that I consider it, that doesn't make too much
sense with floating point numbers.
Thanks for informing me that we can overwrite the parse/writing
function. If we decide to preserve our current (double precision)
information in the PDF file, it is good to know that round-tripping it
back will not be a problem if we so choose. We will keep in mind that
the native renderer might have limitations in reading/rendering such
A: The PDFNet SDK renderer does not have limitations when it comes to
working with doubles, so you will be safe even implementing your own
number reading/writing functions.