I have noticed that every time Spire.PDF saves a document, the file gets bigger even if nothing changed.
Here is my code with the current version 7.2.9 for C#:
- Code: Select all
static void Main()
{
PdfDocument doc = new PdfDocument();
doc.SaveToFile("Test0.pdf");
for(int i=1; i<100; i++)
{
doc = new PdfDocument($"Test{i-1}.pdf");
doc.SaveToFile($"Test{i}.pdf");
}
}
The first PDF (Test0.pdf) is 2 KB and the last (Test99) is 1891 KB big!!!!
After searching this forum I found out about the incrementalUpdate property, so I tried it with this:
- Code: Select all
static void Main()
{
PdfDocument doc = new PdfDocument();
doc.FileInfo.IncrementalUpdate = false;
doc.SaveToFile("Test0.pdf");
for(int i=1; i<100; i++)
{
doc = new PdfDocument($"Test{i-1}.pdf");
doc.FileInfo.IncrementalUpdate = false;
doc.SaveToFile($"Test{i}.pdf");
}
}
This helped a lot, the last pdf now is only 37 KB but still way bigger than the initial file.
So I have tried this same loop but using my PDF instead of creating an empty one.
The initial PDF size is 436 KB and after 99 open-and-save operations without incremental update, this PDF is now 740 KB big, which is an increase of 69%.
Is this because of how the PDF standard is defined?
Is this a bug of Spire.PDF or known behaviour which can't be changed?
Thank you for looking into this.