Hi
Hi there,
Hi there
Hi Louis,
Hi
Hi Louis,
Thanks for sharing your source project. I have tested the code and noticed that issue is causing due to image replacement code, so logged a ticket PDFNET-42377 in our issue tracking system for further investigation and rectification. We will keep you updated about the issue resolution progress within this forum thread.
However as a workaround till the issue is further investigated and resolved, you may comment out the image replacement code. It will help you to extract image successfully.
using (Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(filename))
{
for (int i = 1; i <= pdfDocument.Pages.Count; ++i)
{
using (Page page = pdfDocument.Pages[i])
{
for (int y = 1; y <= page.Resources.Images.Count; ++y)
{
string savefile = Path.Combine("E:/Data", string.Format("image_{0}_{1}{2}", i, y, _extenstion));
bool success = true;
using (FileStream fstream = new FileStream(savefile, FileMode.Create))
{
XImage image = page.Resources.Images[y];
try
{
Console.WriteLine("{0} - Colour: {1}, Transparency: {2}", savefile, image.GetColorType(), image.ContainsTransparency);
image.Save(fstream, _format);
}
catch (Exception)
{
Console.WriteLine("Failed to handle image at {0}-{1}", i, y);
success = false;
}
}
if (!success)
{
File.Delete(savefile);
}
}
}
}
pdfDocument.Save("E:/Data/ReplaceImages.pdf");
}
We are sorry for the inconvenience.
Best Regards,
Hi Tilal
Hi Louis,