Skip to content

Commit

Permalink
Symfony4+ compatible (#9)
Browse files Browse the repository at this point in the history
* make it symfony4+ compatible, drop symfony2 support

* update readme - add note about symfony2 release

* add php 7.3 to travis ci
  • Loading branch information
ixarlie authored Nov 25, 2020
1 parent d24ab73 commit baa6a67
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 33 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: php
php:
- "7.3"
- "7.0"
- "5.6"
sudo: false
Expand Down
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ Left to finish
## Usage

Console Usage -
-Generate CSV Export from PDF
- Generate CSV Export from PDF
```
$ /path/to/fdf-utility/bin/fdf wesnick:fdf:csv-export /path/to/my/pdf.pdf path/to/my/csv/csv --pdftk=/path/to/pdftk
```

-Generate Example Filled PDF
- Generate Example Filled PDF
```
$ /path/to/fdf-utility/bin/fdf wesnick:fdf:example-pdf /path/to/my/emtpy-pdf.pdf path/to/my/filled-pdf.pdf --pdftk=/path/to/pdftk
```
Expand All @@ -30,18 +30,17 @@ You can also use the lirbary's components directly. The class PdfForm is a usef

Use composer.

{
"require": {
"wesnick/fdf-utility": "dev-master@dev"
}
}
```
composer require wesnick/fdf-utility
```

## Requirements

PHP 5.6
- PHP 5.5.9 / PHP 7.0 or higher
- Symfony Process (>=3.3 or >=4.0)
- Symfony Console (dev, >=3.3 or >=4.0)

Symfony Process
Symfony Console (dev)
For Symfony versions between >=2.3 and <3.3 use the [release v0.4.3](https://github.com/wesnick/fdf-utility/releases/tag/v0.4.3)

## Acknowledgements

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
}
],
"require": {
"php": ">=5.4",
"symfony/process": "^2.3|^3.0"
"php": "^5.5.9|>=7.0.8",
"symfony/process": "^3.3|^4.0"
},
"require-dev": {
"symfony/console": "^2.3|^3.0",
"symfony/console": "^3.3|^4.0",
"phpunit/phpunit": "^5.7",
"ext-iconv": "*"
},
Expand Down
2 changes: 2 additions & 0 deletions src/Wesnick/FdfUtility/Command/GenerateCsvExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$pdfForm = new PdfForm();
$pdfForm->generateCsvExport($pdftk_path, $source, $target);

return 0;
}
}
2 changes: 2 additions & 0 deletions src/Wesnick/FdfUtility/Command/GenerateExamplePdfCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$pdfForm = new PdfForm();
$pdfForm->generatePdfExample($pdftk_path, $source, $target);

return 0;
}
}
25 changes: 5 additions & 20 deletions src/Wesnick/FdfUtility/PdfForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Wesnick\FdfUtility;

use Symfony\Component\Process\ProcessBuilder;
use Symfony\Component\Process\Process;
use Wesnick\FdfUtility\Parser\PdftkDumpParser;

/**
Expand All @@ -20,9 +20,8 @@ public static function extractFieldsFromPdf($pdftkBinary, $pdf)
{
$fields_dump = tempnam(sys_get_temp_dir(), 'fdf_dump');

$processBuilder = self::buildPdftkProcess($pdftkBinary);
$processBuilder->setArguments([$pdf, 'dump_data_fields_utf8', 'output', $fields_dump]);
$processBuilder->getProcess()->mustRun();
$process = new Process([$pdftkBinary, $pdf, 'dump_data_fields_utf8', 'output', $fields_dump]);
$process->mustRun();

$parser = new PdftkDumpParser($fields_dump);
$fields = $parser->parse();
Expand All @@ -49,9 +48,8 @@ public static function generatePdfExample($pdftkBinary, $sourcePdf, $targetPdf)
$writer->generate();
$writer->save($fdf_file);

$processBuilder = self::buildPdftkProcess($pdftkBinary);
$processBuilder->setArguments([$sourcePdf, 'fill_form', $fdf_file, 'output', $targetPdf]);
$processBuilder->getProcess()->mustRun();
$process = new Process([$pdftkBinary, $sourcePdf, 'fill_form', $fdf_file, 'output', $targetPdf]);
$process->mustRun();

unlink($fdf_file);
}
Expand Down Expand Up @@ -118,17 +116,4 @@ public static function generateCsvExport($pdftkBinary, $sourcePdf, $targetFile)
}
fclose($handle);
}

/**
* @param string $pdftkBinary
*
* @return ProcessBuilder
*/
private static function buildPdftkProcess($pdftkBinary)
{
$processBuilder = new ProcessBuilder();
$processBuilder->setPrefix($pdftkBinary);

return $processBuilder;
}
}

0 comments on commit baa6a67

Please sign in to comment.