diff --git a/README.md b/README.md index dd8ec9a..aaccefb 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file diff --git a/app.php b/app.php index 4c82f1d..e3f55f2 100644 --- a/app.php +++ b/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."; } } ); diff --git a/locale/application.pot b/locale/application.pot index ffa4913..aa08a1d 100644 --- a/locale/application.pot +++ b/locale/application.pot @@ -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 \n" "Language-Team: LANGUAGE \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 "" diff --git a/locale/application_7b6a264dde56b2de3396e3739e066007.pot b/locale/application_35294e16757c3d30edc4fc9ce3867679.pot similarity index 100% rename from locale/application_7b6a264dde56b2de3396e3739e066007.pot rename to locale/application_35294e16757c3d30edc4fc9ce3867679.pot diff --git a/locale/ar/LC_MESSAGES/application.po b/locale/ar/LC_MESSAGES/application.po index b04f3cf..750c35c 100644 --- a/locale/ar/LC_MESSAGES/application.po +++ b/locale/ar/LC_MESSAGES/application.po @@ -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 \n" "Language-Team: Arabic \n" "Language-Team: French \n" "Language-Team: Kabyle \n" "Language-Team: Occitan 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); + } } \ No newline at end of file diff --git a/templates/compress.html.php b/templates/compress.html.php index 6576e5e..8d493ea 100644 --- a/templates/compress.html.php +++ b/templates/compress.html.php @@ -29,6 +29,11 @@ " class="form-control form-control-lg" type="file" accept=".pdf,application/pdf" onchange="handleFileChange()" />

+ +
+

+
+