Skip to content
Snippets Groups Projects
Commit e811c2d1 authored by Jean-Laurent DUZANT's avatar Jean-Laurent DUZANT
Browse files

FIX TIME 0:10 use getSetaPdfFormFillerLibrary and not getSetaSignFormFillerLibrary

parent 4ddbc6ad
No related branches found
No related tags found
No related merge requests found
......@@ -62,6 +62,7 @@ class WatermarkController
$fileContent = null;
try {
$flattenedFile = null;
$watermarkFile = CoreConfigModel::getTmpPath() . "tmp_file_{$GLOBALS['id']}_" .rand(). "_watermark.pdf";
file_put_contents($watermarkFile, base64_decode($args['encodedDocument']));
......@@ -70,6 +71,22 @@ class WatermarkController
return $fileContent;
}
$libPath = CoreConfigModel::getSetaPdfFormFillerLibrary();
if (!empty($libPath)) {
require_once($libPath);
$flattenedFile = CoreConfigModel::getTmpPath() . "tmp_file_{$GLOBALS['id']}_" .rand(). "_watermark.pdf";
$writer = new \SetaPDF_Core_Writer_File($flattenedFile);
$document = \SetaPDF_Core_Document::loadByFilename($watermarkFile, $writer);
$formFiller = new \SetaPDF_FormFiller($document);
$fields = $formFiller->getFields();
$fields->flatten();
$document->save()->finish();
$watermarkFile = $flattenedFile;
}
$pdf = new Fpdi('P', 'pt');
$nbPages = $pdf->setSourceFile($watermarkFile);
$pdf->setPrintHeader(false);
......@@ -85,6 +102,10 @@ class WatermarkController
$pdf->Text(8, $watermark['posY'], $text, false, false, true, 0, 0, $watermark['align']); // Position X = 8
}
$fileContent = $pdf->Output('', 'S');
if (!empty($flattenedFile) && is_file($flattenedFile)) {
unlink($flattenedFile);
}
} catch (\Exception $e) {
$fileContent = null;
}
......@@ -94,11 +115,11 @@ class WatermarkController
public static function checkDocumentSignatureField(array $args)
{
$libDir = CoreConfigModel::getLibrariesDirectory();
$libPath = CoreConfigModel::getSetaPdfFormFillerLibrary();
$alreadySigned = false;
if (!empty($libDir) && is_file($libDir . 'SetaPDF-FormFiller-Full/library/SetaPDF/Autoload.php')) {
require_once($libDir . 'SetaPDF-FormFiller-Full/library/SetaPDF/Autoload.php');
if (!empty($libPath) && is_file($libPath)) {
require_once($libPath);
$targetFile = CoreConfigModel::getTmpPath() . "tmp_file_{$GLOBALS['id']}_" . rand() . "_target_watermark.pdf";
file_put_contents($targetFile, base64_decode($args['encodedDocument']));
......@@ -122,4 +143,5 @@ class WatermarkController
return $alreadySigned;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment