Hi there,
Thanks for your inquiry. Please check following code to compress images within PDF document, without extracting images. Later you can try to optimize the document. Hopefully it will serve the purpose. If issue persist then can you please share your sample document via some free file sharing services e.g. Dropbox, Skydrive etc? So we will test the scenario at our end and will provide you more information accordingly.
Document pdfDocument = new Aspose.Pdf.Document(“input.pdf”);
foreach (Page page in pdfDocument.Pages)
{
int idx = 1;
foreach (Aspose.Pdf.XImage image in page.Resources.Images)
{
using (var imageStream = new MemoryStream())
{
image.Save(imageStream, ImageFormat.Png);
imageStream.Seek(0, SeekOrigin.Begin);
page.Resources.Images.Replace(idx, imageStream);
}
idx = idx + 1;
}
}
pdfDocument.Save(“output.pdf”);
Please feel free to contact us for any further assistance.
Best Regards,