Free Support Forum - aspose.com

Pdf-png dpi

Is the maximum DPI for extracting images from a pdf file to a png file 100? In the code examples it appears this way, I just wanted to confirm this.

Thanks!

Hi Hagar,


Thanks for your inquiry. I’m moving your query to the related forum; Aspose.Pdf. There one of my Colleagues will guide you properly.

Best Regards,

Hi Hagar,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Sorry for a delay in response.

I am a representatice of Aspose.Pdf team. Well, if you are using XImage.Save method to save the extracted images, the default resolution which will be used is 150. However, in case you need to set the resolution manually, you should use ImagePlacementAbsorber by retrieving image resolution as per the PDF document dimensions (computed the same way like Adobe does). Please see the following sample code in this regard.

// Open document

Document doc = new Document("input.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.Png);

Bitmap image = (Bitmap)Bitmap.FromStream(imageStream);

// set actial resolution for the image

image.SetResolution(imagePlacement.Resolution.X, imagePlacement.Resolution.Y);

image.Save(string.Format("output.png", imageIndex++), ImageFormat.Png);

}

}

Please feel free to contact support in case you have any further query.

Sorry for the inconvenience,