Dear Aspose Team,
I need get RawFormat from XImages from PDFDocument.Pages.Resources.Images to save them before treatment to reduce their weight, but the XImages doesn’t have this method.
How can do this?
Best regards.
Hi Dimitri,
Document pdfDocument
= new Aspose.Pdf.Document(myDir
- “Doc_ORIGINAL.pdf”);<o:p></o:p>
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.Jpeg, 72);
imageStream.Seek(0, SeekOrigin.Begin);
page.Resources.Images.Replace(idx, imageStream);
}
idx = idx + 1;
}
}
//optimize the file size
//pdfDocument.Optimize();
//pdfDocument.OptimizeSize = true;
//pdfDocument.OptimizeResources(new Document.OptimizationOptions() { RemoveUnusedStreams = true, RemoveUnusedObjects = true, LinkDuplcateStreams = true });
// save updated file
pdfDocument.Save(myDir + "Images_Compressed_output_optimize.pdf");
}
Please feel free to contact us for any further assistance.
Best Regards,
Dear Aspose Team,
Thanks the reply.
However, I try still try this only in PNG format, because some pictures in PDF document have transparency levels. So, some pictures weight grews up and the PDF document too.
I wait for your notification about request.
Best regards.
Hi Dimitri,
Thanks for your feedback. We would like to inform you that It is not possible to provide RawFormat because images are stored in PDF specific formats. Please share some details how you will use RawFormat.
We can not provide raw format like JPEG or PNG, but we can provide the image transparency information that can help to decide preferable image file format for saving: JPEG or PNG.
Best Regards,
Dear Aspose Team,
Thanks for the reply.
I’m very interested about get the transparancy information to save pictures in JPEG or PNG.
About the using of RawFormat, I use a library to retreat pictures and reduce their weight but I need the picture format.
Best Regards
Hi Dimitri,
The issues you have found earlier (filed as PDFNEWNET-36693) have been fixed in Aspose.Pdf for .NET 9.9.0.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.