|
Rank: Member Groups: Member
Joined: 8/30/2018 Posts: 15
|
Using EO.pdf with NuGet <package id="EO.Pdf" version="18.2.74" targetFramework="net462" /> When I saved a PDF twice, I got different file sizes. 68K and 100K. Why ?
Code: C#
var pdfDocument = new PdfDocument();
HtmlToPdf.ConvertHtml("This is a test", pdfDocument);
pdfDocument.Save(@"C:\Temp\test.pdf");
pdfDocument.Save(@"D:\Backups\test.pdf");
Then I tested more. Two loops, A and B, saving in two different ways. For loop B, the PDF filesize increase for every save.
Code: C#
PdfDocument pdfDocument;
var prevSize = 0;
//Loop A
for (var i = 0; i < 20; i++)
{
pdfDocument = new PdfDocument();
HtmlToPdf.ConvertHtml("This is a test", pdfDocument);
var s = new MemoryStream();
pdfDocument.Save(s);
var pdfSize = s.ToArray().Length;
Console.WriteLine("A: PdfSize is " + pdfSize + " bytes" + (i > 0 ? " Size increase: " + (pdfSize - prevSize) : ""));
prevSize = pdfSize;
}
//Loop B
pdfDocument = new PdfDocument();
HtmlToPdf.ConvertHtml("This is a test", pdfDocument);
for (var i = 0; i < 20; i++)
{
var s = new MemoryStream();
pdfDocument.Save(s);
var pdfSize = s.ToArray().Length;
Console.WriteLine("B: PdfSize is " + pdfSize + " bytes" + (i > 0 ? " Size increase: " + (pdfSize - prevSize) : ""));
prevSize = pdfSize;
}
OUTPUT:
A: PdfSize is 69099 bytes
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
A: PdfSize is 69099 bytes Size increase: 0
B: PdfSize is 69099 bytes
B: PdfSize is 101948 bytes Size increase: 32849
B: PdfSize is 134831 bytes Size increase: 32883
B: PdfSize is 167689 bytes Size increase: 32858
B: PdfSize is 200547 bytes Size increase: 32858
B: PdfSize is 233405 bytes Size increase: 32858
B: PdfSize is 266263 bytes Size increase: 32858
B: PdfSize is 299121 bytes Size increase: 32858
B: PdfSize is 331979 bytes Size increase: 32858
B: PdfSize is 364838 bytes Size increase: 32859
B: PdfSize is 397697 bytes Size increase: 32859
B: PdfSize is 430556 bytes Size increase: 32859
B: PdfSize is 463415 bytes Size increase: 32859
B: PdfSize is 496274 bytes Size increase: 32859
B: PdfSize is 529133 bytes Size increase: 32859
B: PdfSize is 561992 bytes Size increase: 32859
B: PdfSize is 594855 bytes Size increase: 32863
B: PdfSize is 627724 bytes Size increase: 32869
B: PdfSize is 660593 bytes Size increase: 32869
B: PdfSize is 693462 bytes Size increase: 32869
Is there a bug here ? Of course, I could instead saved the bytearray twice.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi,
This issue is related to the trial version and it should not occur once you apply the license key.
Without a license key, EO.Pdf would try to stamp the output file with a license warning message every time you call Save --- this does not occur in all cases but your case has triggered this. The additional file size is triggered by this process. Once you apply license key, it will not longer attempt to stamp the license warning message and the file size should stay constant throughout multiple Saves.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 8/30/2018 Posts: 15
|
Thanks, Unfortunate behavior, but okay. I evaluate Your software to find a new PDF tool, but such "features" can easily cause other providers to be chosen. Then you had luck that I asked you for support on this one :-)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Yes. We did get lucky. :) We shall investigate this and see if we can smooth this one out. :)
|
|