From 2201a1879194fa418a860c81116efb5612ae7f66 Mon Sep 17 00:00:00 2001 From: Adam Prager Date: Fri, 7 Jul 2017 13:58:28 +0200 Subject: [PATCH] [Standard] PDF/X-1a --- Standard/StandardInterface.php | 16 ++++++++ Standard/X1a.php | 67 ++++++++++++++++++++++++++++++++++ test.php | 49 +++---------------------- 3 files changed, 88 insertions(+), 44 deletions(-) create mode 100644 Standard/StandardInterface.php create mode 100644 Standard/X1a.php diff --git a/Standard/StandardInterface.php b/Standard/StandardInterface.php new file mode 100644 index 0000000..74ce45a --- /dev/null +++ b/Standard/StandardInterface.php @@ -0,0 +1,16 @@ +getRules() as $rule) { + $errors[get_class($rule)] = $rule->validate($document); + } + + return $errors; + } +} diff --git a/test.php b/test.php index c1ba5c1..77e1fc4 100644 --- a/test.php +++ b/test.php @@ -4,15 +4,9 @@ include 'vendor/autoload.php'; -use Padam87\PdfPreflight\Rule\MaxInkDensityImage; -use Padam87\PdfPreflight\Rule\MaxInkDensityText; -use Padam87\PdfPreflight\Rule\NoRgbImages; -use Padam87\PdfPreflight\Rule\ImageMinDpi; -use Padam87\PdfPreflight\Rule\NoRgbText; -use Padam87\PdfPreflight\Rule\RuleInterface; +use Padam87\PdfPreflight\Standard\X1a; use Smalot\PdfParser\Object as XObject; use Smalot\PdfParser\Parser; -use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\VarDumper\Cloner\Stub; use Symfony\Component\VarDumper\Cloner\VarCloner; use Symfony\Component\VarDumper\Dumper\CliDumper; @@ -35,45 +29,12 @@ $dumper->dump($cloner->cloneVar($var)); }); -/** @var RuleInterface[] $rules */ -$rules = [ - new ImageMinDpi(), - new NoRgbImages(), - new NoRgbText(), - new MaxInkDensityImage(300), - new MaxInkDensityText(100), -]; - -$stopwatch = new Stopwatch(); -$stopwatch->start('parse'); - $parser = new Parser(); //$document = $parser->parseFile('./gls.pdf'); -$document = $parser->parseFile('./test.pdf'); - -$event = $stopwatch->stop('parse'); - -dump($event->getDuration()); - -$stopwatch->start('preflight'); - -foreach ($rules as $rule) { - $errors = $rule->validate($document); - - $event = $stopwatch->lap('preflight'); - $periods = $event->getPeriods(); - $period = end($periods); - - dump( - [ - 'rule' => get_class($rule), - 'errors' => $errors, - 'duration' => $period->getDuration(), - ] - ); -} +//$document = $parser->parseFile('./test.pdf'); +$document = $parser->parseFile('./hotel.pdf'); -$event = $stopwatch->stop('preflight'); +$standard = new X1a(); -dump($event->getDuration()); +dump($standard->validate($document));