A lightweight PHP service for converting PDF files into images using pdftoppm
. Supports PNG output and generates images for each page in the PDF.
- Converts PDF files into images (PNG format).
- Outputs one image per page in the PDF.
- Lightweight and easy to integrate.
- PHP 7.4 or higher.
pdftoppm
installed on the server (part ofpoppler-utils
).
- Clone the repository:
git clone https://github.com/m-ah07/PDF-to-Images-Conversion-php.git
- Install
pdftoppm
(if not already installed):sudo apt install poppler-utils
Use the provided example script in the examples/
directory:
require_once __DIR__ . '/../src/PdfToImages.php';
use PdfToImages\PdfToImages;
$pdfPath = __DIR__ . '/sample.pdf';
$outputDir = __DIR__ . '/output';
$converter = new PdfToImages($pdfPath, $outputDir);
$images = $converter->convert();
print_r($images);
Place a sample PDF in the examples/
folder and run the script:
php examples/example.php
PDF-to-Images-Conversion-php/
├── examples/
│ └── example.php
├── src/
│ └── PdfToImages.php
├── LICENSE
├── .gitignore
└── README.md
Contributions are welcome! Feel free to submit a pull request or open an issue to report bugs or suggest features.
If you found this project helpful, please consider giving it a ⭐ on GitHub. Your support means the world to us!