Hi friends I'm new to Codeigniter . In my new project i've a task to upload a pdf file and i've to convert it to an image . could any one suggest me solution is there is any library function to convert it and also get me some working code if possible . Thanks in advance
Asked
Active
Viewed 8,841 times
-1
-
You need to extract images from PDF? – AddWeb Solution Pvt Ltd Jan 19 '16 at 07:14
3 Answers
0
You can convert (Split) PDF files into images with ImageMagick and GhostScript. Checkout this PHP library here.
This class can be used to convert PDF documents to images using Ghostscript. It takes an uploaded PDF file and converts it into JPEG images using the Ghostscript program.
NOTE: The converted images are stored in files numbered according to the respective PDF document page.

AddWeb Solution Pvt Ltd
- 21,025
- 5
- 26
- 57
0
You can use PDFlib php wrapper which I wrote sometime back, use it like below
$pdflib = new ImalH\PDFLib\PDFLib();
$pdflib->setPdfPath("pdf file path");
$pdflib->setOutputPath("output folder path");
$pdflib->setImageFormat(\ImalH\PDFLib\PDFLib::$IMAGE_FORMAT_PNG);
$pdflib->setDPI(300);
$pdflib->setPageRange(1,$pdflib->getNumberOfPages());
$pdflib->convert();

Imal Hasaranga Perera
- 9,683
- 3
- 51
- 41
-1
with a simple google, i got this answer from somewhere else.
The image library supports ImageMagick if you have it installed on your server: https://ellislab.com/codeigniter/user-guide/libraries/image_lib.html
$config = array(
'image_library' => 'imagemagick',
'library_path' => 'imagemagick_file_path_goes_here',
'source_image' => $pdf_path,
'new_image' => $img_path,
'maintain_ratio' => true,
'width' => 365,
'quality' => '100%',
);
$this->image_lib->initialize( $config );
if ( $this->image_lib->resize( ) ) {
$this->image_lib->clear( );
}

Programmer
- 307
- 3
- 17