On this page
Guides
Convert PDF to Image
Overview
ComPDFKit Conversion SDK provides an API for converting PDF to images. Integrate ComPDFKit Conversion SDK to your apps to convert PDF into images easily. Supported image formats inlude PNG and JPEG.
About the picture DPI
The default DPI (Dots Per Inch) for most images is set to 72 DPI. Set the image DPI to 72, ensuring the output matches the PDF's original resolution. To scale the resolution of the output image to certain times, change the DPI 72 to certain times.
Notice
- The higher the image DPI setting, the greater the resolution of the produced image. However, this also means that it will consume more memory during processing and will slow down the operation.
- A higher DPI setting does not necessarily equate to a higher clarity in the image. The sharpness of the image also depends on the resolution of the original document's image.
Sample
This sample demonstrates how to convert from a PDF to Image file.
c#
string inputFilePath = "***";
string outputFolderPath = "***";
string outputFileName = "***";
CPDFConverterImg converter = CPDFConvertFactroy.CreateConverter(CPDFConvertType.CPDFConvertTypeImg, inputFilePath) as CPDFConverterImg;
CPDFConvertImgOptions imgOptions = new CPDFConvertImgOptions();
imgOptions.ImageType = ImgType.PNG;
imgOptions.ImageDpi = 200;
imgOptions.IsContainAnnotations = true;
int pageCount = converter.GetPagesCount();
int[] pageArray = new int[pageCount];
for (int i = 0; i < pageArray.Length; i++)
{
pageArray[i] = i + 1;
}
ConvertError error = ConvertError.ERR_UNKNOWN;
converter.Convert(outputFolderPath, ref outputFileName, imgOptions, pageArray, ref error, getPorgress);