PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
ComPDF Conversion SDK provides an API for converting PDF to images. Integrate ComPDF Conversion SDK to your apps to convert PDF into images easily.
In ComPDF Conversion SDK, supported image formats include:
Supported image color modes in ComPDF Conversion SDK include:
ImageColorMode::COLOR): Color mode, where the image effect is consistent with the original PDF page.ImageColorMode::GRAY): Grayscale mode.ImageColorMode::BINARY): Black and white mode, which applies binarization to the original effect.The SDK supports setting image scaling. The default scaling is 1.0, which maintains the original PDF page size. If you want to double the image size, you can set imageScaling to 2.0; similarly, to reduce the image size by half, set imageScaling to 0.5.
The SDK supports an option called imagePathEnhance for enhancing the display of image paths. This option can be enabled when you want to enhance the display effect of paths within the PDF page.
imageScaling value results in images with higher resolution, but it also increases memory usage and slows down the conversion.imageScaling value does not necessarily equate to higher clarity; the clarity also depends on the original image resolution in the document.The following complete example code demonstrates how to convert a PDF document into PNG format.
use ComPDFKit\Conversion\ImageType;
$option = new ConvertOption();
// Convert PDF to Image (JPEG).
$option->imageType = ImageType::JPEG;
Conversion::convert('Image', 'jpeg.pdf', 'password', 'output_jpeg', $option);
// Convert PDF to Image (PNG) and set imageScaling to double the original PDF size.
$option->imageType = ImageType::PNG;
$option->imageScaling = 2.0;
Conversion::convert('Image', 'png.pdf', 'password', 'output_png', $option);