trekksoft / pdfversion
Reads the version of a PDF file.
2.0.0
2015-09-25 23:01 UTC
Requires
- php: >=5.5
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2024-10-11 03:36:22 UTC
README
Read the version of PDF files using PHP.
Installation
composer require "trekksoft/pdfversion":"~2.0"
Examples
Simple example
<?php
use Trekksoft\PdfVersion\File;
use Trekksoft\PdfVersion\VersionDiscovery\HeaderCommentDiscoverer;
use Trekksoft\PdfVersion\VersionDiscovery\UnknownVersionException;
$file = new File('path/to/file.pdf');
$discoverer = new HeaderCommentDiscoverer();
try {
$version = $discoverer->getVersion($file);
echo $version->toString();
} catch (UnknownVersionException $e) {
echo $e->getMessage();
}
Trying multiple discoverers
$file = new File('path/to/file.pdf');
$discovererChain = new DiscovererChain([
new HeaderCommentDiscoverer(),
new YourOwnDiscoverer(),
new SorryIhaventWrittenAnyOtherDiscoverers(),
]);
$version = $discovererChain->getVersion($file);
Using streams
<?php
$stream = new Stream($fileHandle);
$discoverer = new HeaderCommentDiscoverer();
$version = $discoverer->getVersion($stream);
License
MIT. See LICENSE file.