Hi Adrian,
Thanks for your patience.
We have further investigated the issue PDFNEWNET-33452 and have come to the conclusion that it is quite impossible to retrieve original resolution of an embedded image. Please note that XImage.Save methods always retrieve images with 150 dpi by default.
However you may consider using other Save method overloads that accept resolution parameter, but this is a way to manually set the resolution for the generated images. And there is a way to retrieve image resolution relative to pdf document dimensions (computed the same way like Adobe does).
The ImagePlacementAbsorber functionality must be used to do it: Please have a look over the following code snippet.
[C#]
// Open document
Document doc = new
Document("d:/pdftest/savedFromWord.pdf");
// Create ImagePlacementAbsorber object
to perform image placement search
ImagePlacementAbsorber abs = new
ImagePlacementAbsorber();
// Accept the absorber for first page
doc.Pages.Accept(abs);
int imageIndex = 1;
// Retrieve images with visible
dimensions
foreach (ImagePlacement
imagePlacement in abs.ImagePlacements)
{
using (MemoryStream
imageStream = new MemoryStream())
{
// Retrieve image from resources
imagePlacement.Image.Save(imageStream, ImageFormat.Jpeg);
Bitmap image = (Bitmap)Bitmap.FromStream(imageStream);
// set actial resolution for the image
image.SetResolution(imagePlacement.Resolution.X,
imagePlacement.Resolution.Y);
image.Save("d:/pdftest/savedFromWord"
+ imageIndex.ToString() + ".jpeg",
ImageFormat.Jpeg);
imageIndex++;
}
}
I have tested the scenario using current release version of Aspose.Pdf for .NET 7.0.0 and as per my observations, the resolution of extracted images is much better. Please try using it and in case you still encounter the same problem or you have any further query, please feel free to contact. We are sorry for the delay and inconvenience.