PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

Fix for Issue with Long, Whole Numbers as Reals
http://forum.pdfsharp.de/viewtopic.php?f=3&t=3937
Page 1 of 1

Author:  nbrady [ Thu Mar 21, 2019 8:00 pm ]
Post subject:  Fix for Issue with Long, Whole Numbers as Reals

Found and fixed an issue when a real number is a very large whole number.

What was happening is that value (which was imported from a separate PDF) was being written as an integer when saved (i.e. no decimal point added), causing an overflow both in PdfSharp and Acrobat Reader when the file was opened.

In PdfWriter.cs, about line 169:
Code:
/// <summary>
/// Writes the specified value to the PDF stream.
/// </summary>
public void Write(PdfReal value)
{
            WriteSeparator(CharCat.Character);
            WriteRaw(value.Value.ToString("0.0#######", CultureInfo.InvariantCulture));
            // ORIGINAL WriteRaw(value.Value.ToString(Config.SignificantFigures7, CultureInfo.InvariantCulture));
            _lastCat = CharCat.Character;
}


The above forces a ".0" after the integral value. Probably a more elegant way to do it (don't necessarily need the zero, for example), but for what it's worth.

Cheers,
Nathan Brady

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/