anton-am / pdf-version-converter
PHP library for converting the version of PDF files (for compatibility purposes).
1.0.8
2023-03-16 11:08 UTC
Requires
- php: >=7.2.5
- symfony/filesystem: ^5.0
- symfony/process: ^6.0
Requires (Dev)
- jakub-onderka/php-parallel-lint: ^1.0.0
- phpspec/prophecy-phpunit: ^2.0
- phpstan/phpstan: ^1.10.6
- phpunit/phpunit: ^9.0
README
PHP library for converting the version of PDF files (for compatibility purposes).
Requirements
- PHP 7.2.5+
- Ghostscript (gs command on Linux)
Installation
Run php composer.phar require xthiago/pdf-version-converter dev-master
or add the follow lines to composer and run composer install
:
{
"require": {
"anton-am/pdf-version-converter": "^1.0.6"
}
}
Usage
Guessing a version of PDF File:
<?php // import the composer autoloader require_once __DIR__.'/vendor/autoload.php'; // import the namespaces use AntonAm\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, AntonAm\PDFVersionConverter\Converter\GhostscriptConverterCommand, AntonAm\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
.