fabianogaldino / pdf-version-converter
PHP library for converting the version of PDF files (for compatibility purposes).
Installs: 384
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 77
pkg:composer/fabianogaldino/pdf-version-converter
Requires
- php: ^7.2.5 || ^8.0
- symfony/filesystem: ^5.0
- symfony/process: ^5.4
Requires (Dev)
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2025-12-24 07:34:53 UTC
README
PHP library for converting the version of PDF files (for compatibility purposes).
Requirements
- PHP 7.2+
- Ghostscript (gs command on Linux)
Installation
The package can be installed via composer:
composer require fabianogaldino/pdf-version-converter
Usage
Using simplified class PdfVersionConvert:
$contentConverted = (new \FabianoGaldino\PDFVersionConverter\PdfVersionConverter)->convertTo14(file_get_contents($filename)); $version = (new \FabianoGaldino\PDFVersionConverter\PdfVersionConverter)->guess(file_get_contents($filename));
Guessing a version of PDF File:
<?php // import the composer autoloader require_once __DIR__.'/vendor/autoload.php'; // import the namespaces use FabianoGaldino\PDFVersionConverter\Guesser\RegexGuesser; // [..] $guesser = new RegexGuesser(); echo $guesser->guess('/path/to/my/file.pdf'); // will print something like '1.4'
Converting file to a new PDF version:
<?php // import the composer autoloader require_once __DIR__.'/vendor/autoload.php'; // import the namespaces use Symfony\Component\Filesystem\Filesystem, FabianoGaldino\PDFVersionConverter\Converter\GhostscriptConverterCommand, FabianoGaldino\PDFVersionConverter\Converter\GhostscriptConverter; // [..] $command = new GhostscriptConverterCommand(); $filesystem = new Filesystem(); $converter = new GhostscriptConverter($command, $filesystem); $converter->convert('/path/to/my/file.pdf', '1.4');
Contributing
Is really simple add new implementation of guesser or converter, just implement GuessInterface or ConverterInterface.
Running unit tests
Run phpunit -c tests.