adachsoft / pdf-lib
Implementation of PDF conversion and text extraction using Dompdf and Smalot PdfParser.
v0.1.0
2026-10-08 03:59 UTC
Requires
- php: >=8.3
- adachsoft/collection: ^3.0
- adachsoft/pdf-contracts: ^0.1
- dompdf/dompdf: ^3.0 || ^2.0
- setasign/fpdf: ^1.9
- setasign/fpdi: ^2.6
- smalot/pdfparser: ^2.12
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^12.0 || ^11.0
- rector/rector: ^2.7
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-10-09 09:26:42 UTC
README
adachsoft/pdf-lib provides PDF conversion, text extraction, and page editing services for PHP applications.
Features
- Convert HTML content or HTML files to PDF with Dompdf.
- Extract text and page counts from PDF files with Smalot PdfParser.
- Add, remove, and replace PDF pages with FPDI.
- Create the library services through a single factory.
- Use the contracts provided by
adachsoft/pdf-contractsfor stable service boundaries.
Installation
composer require adachsoft/pdf-lib
The package requires PHP 8.3 or newer.
Usage
Create services with PdfServiceFactory:
use AdachSoft\PdfLib\Factory\PdfServiceFactory;
$converter = PdfServiceFactory::createConverter();
$converter->convert(
'<h1>Hello PDF</h1>',
__DIR__ . '/var/hello.pdf',
);
$extractor = PdfServiceFactory::createExtractor();
$result = $extractor->extractText(__DIR__ . '/var/hello.pdf');
$pageCount = $extractor->getPageCount(__DIR__ . '/var/hello.pdf');
The page editor is also available through the factory:
$editor = PdfServiceFactory::createPageEditor($converter);
$pageCount = $editor->getPageCount(__DIR__ . '/var/source.pdf');
See the conversion example, text extraction example, and page editing example for complete usage patterns.
License
This library is released under the MIT License.