Controlling image size/resolution of exported pdf page

Hi,

is it possible to control the final size / resolution of an exported image from a pdf file/page?

We would like to ensure that the image from any pdf file is correctly sized for the word document,

including ensuring that it fits inside page margins.

Can we query the pdf file for its resolution / page width and height?

And if possible can we use these values to manipulate the resulting image size and resolution?

Thanks,

Hi,

Thank you for considering Aspose.

I think you need to use Aspose.Pdf.Kit.PdfConverter class and use the following method convert Pdf to Image and also set the resolution as well. Please refer to:

public void GetNextImage(
Stream outputStream,
ImageFormat format,
int resolutionX,
int resolutionY,
int quality
);

Thanks.

Hi,

Which are the units for resolution? And for the quality?

Thanks

(I mean, PdfConverter.Resolution, and also resolutionX, resolutionY and quality. Is it dots per inch, or…??)

Thanks

Hi,

Yes, the unit of resolution is dots per inch. And the quality is measurement used in JPEG, with the value from 0 to 100(0 is lowest quality and 100 is highest qulity ).

Thanks,

Quick response!!

Thanks.

Hi,

I’d like to know what is the relationship between PdfConverter.Resolution, and the resolutionX, resolutionY parameters of PdfConverter.GetNextImage(…). How do they affect each other?

I want to obtain an image at a certain resolution(dpi), but I’m not sure how to set those 3 parameters to obtain the desired result.

This is the code:

PdfConverter pdfConv = new PdfConverter();

pdfConv.BindPdf(pdfStream);

pdfConv.StartPage = startPage;
pdfConv.EndPage = endPage;
pdfConv.Resolution = PDF_TO_IMAGE_MAXRESOLUTION;

// convert PDF page to image

pdfConv.DoConvert();

MemoryStream outputStream = new MemoryStream();

if (pdfConv.HasNextImage())
{
// Save image to specific file
pdfConv.GetNextImage(outputStream,
imageFormat,
PDF_TO_IMAGE_MAXRESOLUTION_X,
PDF_TO_IMAGE_MAXRESOLUTION_Y,
JPG_MAXQUALITY)
);
}

return outputStream;


Thanks.

I will discuss this issue with the developers and reply to you. Currently we are on holiday so we might reply to you a little later.

Hi,

Thank you for pointing that out.

When the property PdfConverter.Resolution is set, the 2 parameters (resolution_x, resolution_y) in the method PdfConverter.GetNextImage() takes no effect. Sorry for that we didn't explain this in the documentation.

Thanks,

No worries, thanks for the clarification :slight_smile: