mirror of
https://github.com/24eme/signaturepdf
synced 2026-03-14 13:55:44 +01:00
add watermark via imagick and pdftk
This commit is contained in:
parent
43a12e2d0b
commit
089145fd40
2 changed files with 19 additions and 19 deletions
2
app.php
2
app.php
|
|
@ -220,7 +220,7 @@ $f3->route('POST /sign',
|
|||
PDFSignature::createPDFFromSvg($svgFiles, $tmpfile.'.svg.pdf');
|
||||
PDFSignature::addSvgToPDF($tmpfile.'.pdf', $tmpfile.'.svg.pdf', $tmpfile.'_signe.pdf');
|
||||
if ($filigrane) {
|
||||
PDFSignature::convertTextToFiligrane($filigrane, $tmpfile.'_signe.pdf');
|
||||
PDFSignature::addFiligrane($filigrane, $tmpfile);
|
||||
}
|
||||
|
||||
Web::instance()->send($tmpfile.'_signe.pdf', null, 0, TRUE, $filename);
|
||||
|
|
|
|||
|
|
@ -196,25 +196,25 @@ class PDFSignature
|
|||
}
|
||||
}
|
||||
|
||||
public static function convertTextToFiligrane($text, $outputFile)
|
||||
public static function addFiligrane($text, $pdf)
|
||||
{
|
||||
// Création svg
|
||||
// TODO
|
||||
// Création texte watermark
|
||||
$watermarkCommand = sprintf(
|
||||
'magick -background None -fill "%s" -pointsize 20 label:"%s" -rotate -40 +repage -write mpr:TILE +delete ( %s_signe.pdf[0] -density 288 -fill mpr:TILE -draw "color 0,0 reset" ) %s_wm.pdf',
|
||||
"#444E", $text, $pdf, $pdf);
|
||||
shell_exec(escapeshellcmd($watermarkCommand));
|
||||
|
||||
// conversion du filigrane en pdf
|
||||
shell_exec(sprintf("rsvg-convert -f pdf -o %s %s",
|
||||
escapeshellarg($outputFile.'_filigrane.pdf'),
|
||||
escapeshellarg($outputFile.'_filigrane.svg')
|
||||
));
|
||||
$applyWatermarkCommand = sprintf(
|
||||
'pdftk %s_signe.pdf multistamp %s_wm.pdf output %s_with_watermark.pdf flatten',
|
||||
$pdf, $pdf, $pdf
|
||||
);
|
||||
shell_exec(escapeshellcmd($applyWatermarkCommand));
|
||||
|
||||
// on applique le filigrane
|
||||
shell_exec(sprintf("pdftk %s background %s output %s",
|
||||
escapeshellarg($outputFile),
|
||||
escapeshellarg($outputFile.'_filigrane.pdf'),
|
||||
escapeshellarg($outputFile.'_withfiligrane.pdf')
|
||||
));
|
||||
|
||||
rename($outputFile.'_withfiligrane.pdf', $outputFile);
|
||||
$flattenCommand = sprintf(
|
||||
'magick -density 144 %s_with_watermark.pdf -resize 90%% -compress zip %s_signe.pdf',
|
||||
$pdf, $pdf
|
||||
);
|
||||
shell_exec(escapeshellcmd($flattenCommand));
|
||||
}
|
||||
|
||||
public function clean() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue