Free Support Forum - aspose.com

Loop Images

Is there a way to loop all the image objects in a PDF document?

I am using Aspose.PDF.Generator.PDF

I tried this but it seems that it will only loop imediate paragraphs and I dont see any way to do implement recurtion since the Paragraph does not have a paragraphs collection, here is my code

private void ReplaceImage(Pdf pdf, string id, System.Drawing.Image image, bool fitImage, int destHeight, int destWidth)
{
foreach (Section s in pdf.Sections)
{
for (int i = 0; i < s.Paragraphs.Count; i++)
{
if (s.Paragraphs[i].GetType().ToString() == typeof(Aspose.Pdf.Generator.Image).ToString())
{
if (s.Paragraphs[i].ID == id)
{
s.Paragraphs[i] = Image.FromSystemImage(image);
}
}
}
}

Hello Fernando,

Thanks for using our products.

Do you need to extract or replace the images inside PDF document ? or can you please share some details regarding your actual requirement as it will help us in sharing appropriate information. We are sorry for your inconvenience.

Post 315672 solved my problem thanks