mirror of
https://github.com/24eme/signaturepdf
synced 2024-05-08 16:56:33 +02:00
ajout alerte PDF opti
This commit is contained in:
parent
a72259e56b
commit
072e584381
|
@ -31,6 +31,7 @@ Open-source software under the AGPL V3 license.
|
|||
- [Translation](#translation)
|
||||
- [Contributors](#contributors)
|
||||
- [Fundings](#fundings)
|
||||
- [Screenshots](#screenshots)
|
||||
|
||||
|
||||
## Installation
|
||||
|
@ -162,4 +163,4 @@ Vincent LAURENT (24ème), Jean-Baptiste Le Metayer (24ème), Xavier Garnier (Log
|
|||
- 100 € excl. taxes donations from the company PDG IT
|
||||
- 1 040 € excl. taxes from the foundation NLNet pour software internationalization
|
||||
|
||||
The development of the software was primarily done during the working hours of 24ème employees.
|
||||
The development of the software was primarily done during the working hours of 24ème employees.
|
12
app.php
12
app.php
|
@ -409,8 +409,12 @@ $f3->route('GET /metadata',
|
|||
|
||||
$f3->route('GET /compress',
|
||||
function($f3) {
|
||||
$f3->set('error_message', "none");
|
||||
$f3->set('maxSize', min(array(convertPHPSizeToBytes(ini_get('post_max_size')), convertPHPSizeToBytes(ini_get('upload_max_filesize')))));
|
||||
$f3->set('activeTab', 'compress');
|
||||
if (isset($_GET['err'])) {
|
||||
$f3->set('error_message', "PDF optimized");
|
||||
}
|
||||
echo View::instance()->render('compress.html.php');
|
||||
}
|
||||
);
|
||||
|
@ -438,17 +442,23 @@ $f3->route ('POST /compress',
|
|||
|
||||
$arrayPath = array_keys($files);
|
||||
$filePath = reset($arrayPath);
|
||||
|
||||
$outputFileName = str_replace(".pdf", "_compressed.pdf", $filePath);
|
||||
|
||||
$returnCode = shell_exec(sprintf("gs -sDEVICE=pdfwrite -dPDFSETTINGS=%s -dQUIET -o %s %s", $compressionType, $outputFileName, $filePath));
|
||||
|
||||
if ($returnCode !== false) {
|
||||
if (filesize($filePath) <= filesize($outputFileName)) {
|
||||
$error = "pdfalreadyoptimized";
|
||||
header('location: /compress?err=' . $error);
|
||||
} else {
|
||||
header('Content-Type: application/pdf');
|
||||
header("Content-Disposition: attachment; filename=$outputFileName");
|
||||
readfile($outputFileName);
|
||||
unlink($outputFileName);
|
||||
}
|
||||
} else {
|
||||
echo "PDF compression failed.";
|
||||
echo "PDF compression failed.";
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-09-29 11:52+0200\n"
|
||||
"POT-Creation-Date: 2023-10-24 17:22+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -46,6 +46,9 @@ msgid ""
|
|||
"The PDF will be processed by the server without being retained or stored"
|
||||
msgstr ""
|
||||
|
||||
msgid "Your pdf is already optimized"
|
||||
msgstr ""
|
||||
|
||||
msgid "Compress"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-09-29 11:52+0200\n"
|
||||
"POT-Creation-Date: 2023-10-24 17:21+0200\n"
|
||||
"PO-Revision-Date: 2023-09-29 08:55+0000\n"
|
||||
"Last-Translator: ButterflyOfFire <boffire@users.noreply.hosted.weblate.org>\n"
|
||||
"Language-Team: Arabic <https://hosted.weblate.org/projects/signature-pdf/"
|
||||
|
@ -49,6 +49,9 @@ msgid ""
|
|||
"The PDF will be processed by the server without being retained or stored"
|
||||
msgstr "سيتم معالجة ملف PDF على الخادم دون الاحتفاظ به أو تخزينه"
|
||||
|
||||
msgid "Your pdf is already optimized"
|
||||
msgstr ""
|
||||
|
||||
msgid "Compress"
|
||||
msgstr "ضغط"
|
||||
|
||||
|
|
Binary file not shown.
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-09-29 11:06+0200\n"
|
||||
"POT-Creation-Date: 2023-10-24 17:21+0200\n"
|
||||
"PO-Revision-Date: 2023-09-30 12:59+0000\n"
|
||||
"Last-Translator: ButterflyOfFire <boffire@users.noreply.hosted.weblate.org>\n"
|
||||
"Language-Team: French <https://hosted.weblate.org/projects/signature-pdf/"
|
||||
|
@ -49,6 +49,9 @@ msgid ""
|
|||
"The PDF will be processed by the server without being retained or stored"
|
||||
msgstr "Le PDF sera traité par le serveur sans être conservé ni stocké"
|
||||
|
||||
msgid "Your pdf is already optimized"
|
||||
msgstr "Votre PDF est déja optimisé"
|
||||
|
||||
msgid "Compress"
|
||||
msgstr "Compresser"
|
||||
|
||||
|
|
Binary file not shown.
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-09-29 11:28+0200\n"
|
||||
"POT-Creation-Date: 2023-10-24 17:21+0200\n"
|
||||
"PO-Revision-Date: 2023-09-30 00:00+0000\n"
|
||||
"Last-Translator: R_SACI <rgebbid@gmail.com>\n"
|
||||
"Language-Team: Kabyle <https://hosted.weblate.org/projects/signature-pdf/"
|
||||
|
@ -48,6 +48,9 @@ msgid ""
|
|||
"The PDF will be processed by the server without being retained or stored"
|
||||
msgstr "Afaylu PDF ad yettusesfer s uqeddac war ma yettwaḥraz neɣ yettwasekles"
|
||||
|
||||
msgid "Your pdf is already optimized"
|
||||
msgstr ""
|
||||
|
||||
msgid "Compress"
|
||||
msgstr "Ssed"
|
||||
|
||||
|
|
Binary file not shown.
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-09-29 11:06+0200\n"
|
||||
"POT-Creation-Date: 2023-10-24 17:21+0200\n"
|
||||
"PO-Revision-Date: 2023-09-30 00:00+0000\n"
|
||||
"Last-Translator: Quentin PAGÈS <quentinantonin@free.fr>\n"
|
||||
"Language-Team: Occitan <https://hosted.weblate.org/projects/signature-pdf/"
|
||||
|
@ -48,6 +48,9 @@ msgid ""
|
|||
"The PDF will be processed by the server without being retained or stored"
|
||||
msgstr "Lo servidor tractarà lo PDF sens lo servar o gardar"
|
||||
|
||||
msgid "Your pdf is already optimized"
|
||||
msgstr ""
|
||||
|
||||
msgid "Compress"
|
||||
msgstr "Compressar"
|
||||
|
||||
|
|
|
@ -10,4 +10,26 @@ function handleFileChange() {
|
|||
compressBtn.disabled = true;
|
||||
dropdownCompressBtn.disabled = true;
|
||||
}
|
||||
|
||||
document.getElementById('input_pdf_upload').addEventListener('change', async function(event) {
|
||||
uploadAndLoadPDF(this);
|
||||
});
|
||||
}
|
||||
|
||||
var uploadAndLoadPDF = async function(input_upload) {
|
||||
const cache = await caches.open('pdf');
|
||||
for (let i = 0; i < input_upload.files.length; i++) {
|
||||
if(input_upload.files[i].size > maxSize) {
|
||||
|
||||
alert("Le PDF ne doit pas dépasser " + Math.round(maxSize/1024/1024) + " Mo");
|
||||
break;
|
||||
}
|
||||
let filename = input_upload.files[i].name;
|
||||
let response = new Response(input_upload.files[i], { "status" : 200, "statusText" : "OK" });
|
||||
let urlPdf = '/pdf/'+filename;
|
||||
await cache.put(urlPdf, response);
|
||||
let pdfBlob = await getPDFBlobFromCache(urlPdf);
|
||||
nbPDF++;
|
||||
await loadPDF(pdfBlob, filename, nbPDF);
|
||||
}
|
||||
}
|
|
@ -29,6 +29,11 @@
|
|||
<label class="form-label mt-3" for="input_pdf_upload"><?php echo _("Choose a PDF"); ?> <small class="opacity-75" style="cursor: help" title="<?php echo _("The PDF must not exceed "); ?> <?php echo round($maxSize / 1024 / 1024) ?> <?php echo _("Mb"); ?>"><i class="bi bi-info-circle"></i></small></label>
|
||||
<input name="input_pdf_upload" id="input_pdf_upload" placeholder="<?php echo _("Choose a PDF"); ?>" class="form-control form-control-lg" type="file" accept=".pdf,application/pdf" onchange="handleFileChange()" />
|
||||
<p class="mt-2 small fw-light text-dark"><?php echo _("The PDF will be processed by the server without being retained or stored") ?></p>
|
||||
<?php if ($error_message == "PDF optimized"): ?>
|
||||
<div class="alert alert-danger">
|
||||
<p><?php echo _("Your pdf is already optimized"); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="btn-group">
|
||||
<button type="submit" name="compressionType" value="medium" id="compressBtn" class="btn btn-primary" disabled><i class="bi bi-download"></i> <?php echo _("Compress"); ?></button>
|
||||
<button type="button" id="dropdownMenuReference" class="btn btn-outline-primary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false" data-bs-reference="parent" disabled>
|
||||
|
|
Loading…
Reference in a new issue