Optimize PDF file size using Aspose.PDF for .NET - Size is increasing while adding/replacing images

Hi Aspose,

I found that after processing images, document size grows. Eventually I found that even replacing image with itself results to document size growth, which seems strange to me:

for (var i = 1; i <= Document.Pages.Count; i++)
{
    var page = Document.Pages[i];
    for (var j = 1; j <= page.Resources.Images.Count; j++)
    {
         var imageResource = page.Resources.Images[j];
         // get the original raw image (ToStream)
         var image = imageResource.ToStream();

         page.Resources.Images.Replace(j, image, 100);
    }
 }

I tried few optimizations on saving document but it has no effect:

pdfDoc.EmbedStandardFonts = false;
pdfDoc.OptimizeSize = true;
pdfDoc.OptimizeResources();
pdfDoc.Optimize();
pdfDoc.Save(sNewFilePath);

I use Aspose.PDF 19.4. Sample files (before: SizeGrowsAfterProcessingImages.pdf (116.7 KB)
and after: Processed.pdf (332.1 KB))

Best regards,
Alex Shloma

@licenses

Thank you for contacting support.

We have worked with the data shared by you and have been able to notice the difference in file size. A ticket with ID PDFNET-46309 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

Hi @Farhan.Raza,

Do you have any news about PDF-46309? Sending new pdf file where issue can be easily reproduced. University Standards and Regulations 2011-2012.pdf (1.3 MB)

We have many customers documents with such issue, but can not share due privacy reasons. Our assumption that first of all scanned documents are affected.

Best regards,
Alex Shloma

@licenses

We are afraid any update is not available yet. However, we have recorded the data and comments for our reference. Please note that all forum attachments are accessible to topic owner and Aspose staff only so we assure you about data security and privacy. You may also share the files via personal message by clicking on my username and then message icon.

Hi @Farhan.Raza,

Do you have any ETA for this issue? Without a fix for this, customers are unable to email most PDFs since their file sizes are now much greater than the thresholds they have internally for emailing.

Best regards,
Alex Shloma

@licenses

We are sorry that the ETA is not available yet because of it being pending for investigations. We understand your concerns and will try to schedule it soon, and will inform you about ETA once it is available. We really appreciate your patience and cooperation.

Hi Aspose,

Just want to ask if you have any updates regarding this issue?

Best regards,
Alex Shloma

@licenses,

We regret to inform that issue is still unresolved. We are working on this and will share good news with you soon.