mirror of
https://github.com/24eme/signaturepdf
synced 2026-03-14 13:55:44 +01:00
filigrane: conversion d'un svg filigrané en pdf final
Reste à faire le svg 🙃
This commit is contained in:
parent
a868b3812e
commit
946ae655b6
2 changed files with 25 additions and 0 deletions
4
app.php
4
app.php
|
|
@ -178,6 +178,7 @@ $f3->route('POST /image2svg',
|
|||
$f3->route('POST /sign',
|
||||
function($f3) {
|
||||
$filename = null;
|
||||
$filigrane = $f3->get('POST.filigrane');
|
||||
$tmpfile = tempnam($f3->get('UPLOADS'), 'pdfsignature_sign_'.uniqid("", true));
|
||||
unlink($tmpfile);
|
||||
$svgFiles = [];
|
||||
|
|
@ -215,6 +216,9 @@ $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');
|
||||
}
|
||||
|
||||
Web::instance()->send($tmpfile.'_signe.pdf', null, 0, TRUE, $filename);
|
||||
|
||||
|
|
|
|||
|
|
@ -196,6 +196,27 @@ class PDFSignature
|
|||
}
|
||||
}
|
||||
|
||||
public static function convertTextToFiligrane($text, $outputFile)
|
||||
{
|
||||
// Création svg
|
||||
// TODO
|
||||
|
||||
// conversion du filigrane en pdf
|
||||
shell_exec(sprintf("rsvg-convert -f pdf -o %s %s",
|
||||
escapeshellarg($outputFile.'_filigrane.pdf'),
|
||||
escapeshellarg($outputFile.'_filigrane.svg')
|
||||
));
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
public function clean() {
|
||||
foreach($this->toClean as $path) {
|
||||
if(strpos($path, $this->pathHash) !== false) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue