Verified Commit 52ccd870 authored by Damien's avatar Damien

FEAT #13794 TIME 4:30 Form pdf

parent ad26134e
......@@ -72,6 +72,21 @@ class WatermarkController
$position = count($rawPosition) == 4 ? $rawPosition : $position;
}
if (is_file('vendor/SetaPDF-FormFiller-Full_2.33.0.1425/library/SetaPDF/Autoload.php')) {
require_once 'vendor/SetaPDF-FormFiller-Full_2.33.0.1425/library/SetaPDF/Autoload.php';
$flattenedFile = CoreConfigModel::getTmpPath() . "tmp_file_{$GLOBALS['id']}_" .rand(). "_watermark.pdf";
$writer = new \SetaPDF_Core_Writer_File($flattenedFile);
$document = \SetaPDF_Core_Document::loadByFilename($args['path'], $writer);
$formFiller = new \SetaPDF_FormFiller($document);
$fields = $formFiller->getFields();
$fields->flatten();
$document->save()->finish();
$args['path'] = $flattenedFile;
}
try {
$pdf = new Fpdi('P', 'pt');
$nbPages = $pdf->setSourceFile($args['path']);
......@@ -92,6 +107,10 @@ class WatermarkController
$fileContent = null;
}
if (!empty($flattenedFile) && is_file($flattenedFile)) {
unlink($flattenedFile);
}
return $fileContent;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment