Hi,
We have a lot of files scanned on KODAK scanners and when pass this code to optimize size we have a file 10 times bigger!
With some files, not scanned from KODAK, his code works good. Were is our fault?
We update our DLLs to version 9.3.0 and the problem persists.
Please, what is going wrong with this file?
Attached a file (my Test.pdf) for you test.
CODE 1 - With OptimizeResources: (Original File attached = 2.302KB > Result 30.205KB)
var pdfDocument = new Document(caminho);
foreach (Page page in pdfDocument.Pages)
{
int idx = 1;
foreach (XImage image in page.Resources.Images)
{
using (var imageStream = new MemoryStream())
{
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png, 72);
imageStream.Seek(0, SeekOrigin.Begin);
page.Resources.Images.Replace(idx, imageStream, 80);
}
idx = idx + 1;
}
}
pdfDocument.OptimizeResources(new Document.OptimizationOptions()
{
LinkDuplcateStreams = true,
RemoveUnusedObjects = true,
RemoveUnusedStreams = true
});
pdfDocument.Save(diretorioDeSaida + "\\" + "teste.pdf");
CODE 2 - without OptimizeResources:(Original File attached = 2.302KB > Result 21.384KB)
var pdfDocument = new Document(caminho);
foreach (Page page in pdfDocument.Pages)
{
int idx = 1;
foreach (XImage image in page.Resources.Images)
{
using (var imageStream = new MemoryStream())
{
image.Save(imageStream);
page.Resources.Images.Replace(idx, imageStream, 80);
}
idx = idx + 1;
}
}
pdfDocument.Save(diretorioDeSaida + "\\" + "teste.pdf");
Thanks,