mirror of
https://github.com/24eme/signaturepdf.git
synced 2023-08-25 09:33:08 +02:00
Storing and display filename in sharing mode
This commit is contained in:
parent
0cc5ba6439
commit
1e925a38a0
11
app.php
11
app.php
@ -183,8 +183,9 @@ $f3->route('POST /share',
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}, false, function($fileBaseName, $formFieldName) use ($tmpfile, $filename, &$svgFiles) {
|
}, false, function($fileBaseName, $formFieldName) use ($tmpfile, $filename, $sharingFolder, &$svgFiles) {
|
||||||
if($formFieldName == "pdf") {
|
if($formFieldName == "pdf") {
|
||||||
|
file_put_contents($sharingFolder."filename.txt", $fileBaseName);
|
||||||
return $filename;
|
return $filename;
|
||||||
}
|
}
|
||||||
if($formFieldName == "svg") {
|
if($formFieldName == "svg") {
|
||||||
@ -252,6 +253,10 @@ $f3->route('GET /signature/@hash/pdf',
|
|||||||
$files = scandir($sharingFolder);
|
$files = scandir($sharingFolder);
|
||||||
$originalFile = $sharingFolder.'/original.pdf';
|
$originalFile = $sharingFolder.'/original.pdf';
|
||||||
$finalFile = $sharingFolder.'/'.$f3->get('PARAMS.hash').'.pdf';
|
$finalFile = $sharingFolder.'/'.$f3->get('PARAMS.hash').'.pdf';
|
||||||
|
$filename = $f3->get('PARAMS.hash').'.pdf';
|
||||||
|
if(file_exists($sharingFolder."/filename.txt")) {
|
||||||
|
$filename = file_get_contents($sharingFolder."/filename.txt");
|
||||||
|
}
|
||||||
$layers = [];
|
$layers = [];
|
||||||
foreach($files as $file) {
|
foreach($files as $file) {
|
||||||
if(strpos($file, 'svg.pdf') !== false) {
|
if(strpos($file, 'svg.pdf') !== false) {
|
||||||
@ -259,14 +264,14 @@ $f3->route('GET /signature/@hash/pdf',
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$layers) {
|
if (!$layers) {
|
||||||
Web::instance()->send($originalFile, null, 0, TRUE, $f3->get('PARAMS.hash').'.pdf');
|
Web::instance()->send($originalFile, null, 0, TRUE, $filename);
|
||||||
}
|
}
|
||||||
$bufferFile = str_replace('.pdf', '_tmp.pdf', $originalFile);
|
$bufferFile = str_replace('.pdf', '_tmp.pdf', $originalFile);
|
||||||
shell_exec(sprintf("cp %s %s", $originalFile, $finalFile));
|
shell_exec(sprintf("cp %s %s", $originalFile, $finalFile));
|
||||||
foreach($layers as $layer) {
|
foreach($layers as $layer) {
|
||||||
shell_exec(sprintf("pdftk %1\$s multistamp %2\$s output %3\$s && mv %3\$s %1\$s", $finalFile, $layer, $bufferFile));
|
shell_exec(sprintf("pdftk %1\$s multistamp %2\$s output %3\$s && mv %3\$s %1\$s", $finalFile, $layer, $bufferFile));
|
||||||
}
|
}
|
||||||
Web::instance()->send($finalFile, null, 0, TRUE, $f3->get('PARAMS.hash').'.pdf');
|
Web::instance()->send($finalFile, null, 0, TRUE, $filename);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -968,8 +968,6 @@ var pageSignature = async function(url) {
|
|||||||
modalSigned.show();
|
modalSigned.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
let filename = url.replace('/pdf/', '');
|
|
||||||
document.title = filename + ' - ' + document.title;
|
|
||||||
document.getElementById('page-upload').classList.add('d-none');
|
document.getElementById('page-upload').classList.add('d-none');
|
||||||
document.getElementById('page-signature').classList.remove('d-none');
|
document.getElementById('page-signature').classList.remove('d-none');
|
||||||
fabric.Textbox.prototype._wordJoiners = /[]/;
|
fabric.Textbox.prototype._wordJoiners = /[]/;
|
||||||
@ -987,6 +985,7 @@ var pageSignature = async function(url) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let pdfBlob = null;
|
let pdfBlob = null;
|
||||||
|
let filename = url.replace('/pdf/', '');
|
||||||
|
|
||||||
if(hash) {
|
if(hash) {
|
||||||
var response = await fetch(url);
|
var response = await fetch(url);
|
||||||
@ -994,9 +993,15 @@ var pageSignature = async function(url) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pdfBlob = await response.blob();
|
pdfBlob = await response.blob();
|
||||||
|
if(response.headers.get('Content-Disposition').match(/attachment; filename="/)) {
|
||||||
|
filename = response.headers.get('Content-Disposition').replace(/^[^"]*"/, "").replace(/"[^"]*$/, "");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pdfBlob = await getPDFBlobFromCache(url);
|
pdfBlob = await getPDFBlobFromCache(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.title = filename + ' - ' + document.title;
|
||||||
|
|
||||||
if(!pdfBlob) {
|
if(!pdfBlob) {
|
||||||
document.location = '/signature';
|
document.location = '/signature';
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user