From 67448498ea3b87059c70732886e519785030d801 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sat, 10 Jun 2023 00:46:44 +0100 Subject: [PATCH] documentation stuff and downloer fix for image to pdf --- Dockerfile-ultra-lite | 2 +- Endpoint-groups.md | 35 ++++++++++++++++ README.md | 12 +++++- Version-groups.md | 48 ++++++++++++++++++++++ groups.md | 38 ----------------- src/main/resources/static/js/downloader.js | 33 ++++++++++----- 6 files changed, 117 insertions(+), 51 deletions(-) create mode 100644 Endpoint-groups.md create mode 100644 Version-groups.md delete mode 100644 groups.md diff --git a/Dockerfile-ultra-lite b/Dockerfile-ultra-lite index 4960acc0..ac8579af 100644 --- a/Dockerfile-ultra-lite +++ b/Dockerfile-ultra-lite @@ -8,7 +8,7 @@ COPY build/libs/*.jar app.jar EXPOSE 8080 # Set environment variables -ENV GROUPS_TO_REMOVE=LibreOffice,CLI +ENV GROUPS_TO_REMOVE=CLI # Run the application CMD ["java", "-jar", "/app.jar"] diff --git a/Endpoint-groups.md b/Endpoint-groups.md new file mode 100644 index 00000000..6692a9a2 --- /dev/null +++ b/Endpoint-groups.md @@ -0,0 +1,35 @@ +| Operation | PageOps | Convert | Security | Other | CLI | Python | OpenCV | LibreOffice | OCRmyPDF | Java | Javascript | +|---------------------|---------|---------|----------|-------|------|--------|--------|-------------|----------|----------|------------| +| merge-pdfs | ✔️ | | | | | | | | | ✔️ | | +| multi-page-layout | ✔️ | | | | | | | | | ✔️ | | +| pdf-organizer | ✔️ | | | | | | | | | ✔️ | ✔️ | +| remove-pages | ✔️ | | | | | | | | | ✔️ | | +| rotate-pdf | ✔️ | | | | | | | | | ✔️ | | +| scale-pages | ✔️ | | | | | | | | | ✔️ | | +| split-pdfs | ✔️ | | | | | | | | | ✔️ | | +| file-to-pdf | | ✔️ | | | ✔️ | | | ✔️ | | | | +| img-to-pdf | | ✔️ | | | | | | | | ✔️ | | +| pdf-to-html | | ✔️ | | | ✔️ | | | ✔️ | | | | +| pdf-to-img | | ✔️ | | | | | | | | ✔️ | | +| pdf-to-pdfa | | ✔️ | | | ✔️ | | | | ✔️ | | | +| pdf-to-presentation | | ✔️ | | | ✔️ | | | ✔️ | | | | +| pdf-to-text | | ✔️ | | | ✔️ | | | ✔️ | | | | +| pdf-to-word | | ✔️ | | | ✔️ | | | ✔️ | | | | +| pdf-to-xml | | ✔️ | | | ✔️ | | | ✔️ | | | | +| xlsx-to-pdf | | ✔️ | | | ✔️ | | | ✔️ | | | | +| add-password | | | ✔️ | | | | | | | ✔️ | | +| add-watermark | | | ✔️ | | | | | | | ✔️ | | +| cert-sign | | | ✔️ | | | | | | | ✔️ | | +| change-permissions | | | ✔️ | | | | | | | ✔️ | | +| remove-password | | | ✔️ | | | | | | | ✔️ | | +| add-image | | | | ✔️ | | | | | | ✔️ | | +| change-metadata | | | | ✔️ | | | | | | ✔️ | | +| compare | | | | ✔️ | | | | | | | ✔️ | +| compress-pdf | | | | ✔️ | ✔️ | | | | ✔️ | | | +| extract-image-scans | | | | ✔️ | ✔️ | ✔️ | ✔️ | | | | | +| extract-images | | | | ✔️ | | | | | | ✔️ | | +| flatten | | | | ✔️ | | | | | | | | +| ocr-pdf | | | | ✔️ | ✔️ | | | | ✔️ | | | +| remove-blanks | | | | ✔️ | ✔️ | ✔️ | ✔️ | | | | | +| repair | | | | ✔️ | ✔️ | | | ✔️ | | | | +| sign | | | | ✔️ | | | | | | | ✔️ | diff --git a/README.md b/README.md index c9b411d0..39f0367a 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ Hosted instance/demo of the app can be seen [here](https://pdf.adminforge.de/) h ## Technologies used - Spring Boot + Thymeleaf - PDFBox +- IText7 - [LibreOffice](https://www.libreoffice.org/discover/libreoffice/) for advanced conversions - [OcrMyPdf](https://github.com/ocrmypdf/OCRmyPDF) - HTML, CSS, JavaScript @@ -68,13 +69,20 @@ Please view https://github.com/Frooodle/Stirling-PDF/blob/main/LocalRunGuide.md ### Docker https://hub.docker.com/r/frooodle/s-pdf +Stirling PDF has 3 different versions, a Full version, Lite and ultra-Lite. Depending on the types of features you use you may want a smaller image to save on space. +To see what the different versions offer please look at our [version mapping](https://github.com/Frooodle/Stirling-PDF/blob/main/Version-groups.md) +For people that dont mind about space optimisation just use latest tag. +![Docker Image Size (tag)](https://img.shields.io/docker/image-size/frooodle/s-pdf/latest?label=Stirling-PDF%20Full) +![Docker Image Size (tag)](https://img.shields.io/docker/image-size/frooodle/s-pdf/latest-lite?label=Stirling-PDF%20Lite) +![Docker Image Size (tag)](https://img.shields.io/docker/image-size/frooodle/s-pdf/latest-ultra-lite?label=Stirling-PDF%20Ultra-Lite) + Docker Run ``` docker run -d \ -p 8080:8080 \ -v /location/of/trainingData:/usr/share/tesseract-ocr/4.00/tessdata \ --name stirling-pdf \ - frooodle/s-pdf + frooodle/s-pdf:latest Can also add these for customisation but are not required @@ -90,7 +98,7 @@ Docker Compose version: '3.3' services: stirling-pdf: - image: frooodle/s-pdf + image: frooodle/s-pdf:latest ports: - '8080:8080' volumes: diff --git a/Version-groups.md b/Version-groups.md new file mode 100644 index 00000000..244284c7 --- /dev/null +++ b/Version-groups.md @@ -0,0 +1,48 @@ +|Technology | Ultra-Lite | Lite | Full | +|----------------|:----------:|:----:|:----:| +| Java | ✔️ | ✔️ | ✔️ | +| JavaScript | ✔️ | ✔️ | ✔️ | +| Libre | | ✔️ | ✔️ | +| Python | | | ✔️ | +| OpenCV | | | ✔️ | +| OCRmyPDF | | | ✔️ | + + + + + +Operation | Ultra-Lite | Lite | Full +--------------------|------------|------|----- +add-password | ✔️ | ✔️ | ✔️ +add-watermark | ✔️ | ✔️ | ✔️ +cert-sign | ✔️ | ✔️ | ✔️ +change-metadata | ✔️ | ✔️ | ✔️ +change-permissions | ✔️ | ✔️ | ✔️ +compare | ✔️ | ✔️ | ✔️ +extract-images | ✔️ | ✔️ | ✔️ +flatten | ✔️ | ✔️ | ✔️ +img-to-pdf | ✔️ | ✔️ | ✔️ +merge-pdfs | ✔️ | ✔️ | ✔️ +multi-page-layout | ✔️ | ✔️ | ✔️ +pdf-organizer | ✔️ | ✔️ | ✔️ +pdf-to-img | ✔️ | ✔️ | ✔️ +remove-pages | ✔️ | ✔️ | ✔️ +remove-password | ✔️ | ✔️ | ✔️ +rotate-pdf | ✔️ | ✔️ | ✔️ +scale-pages | ✔️ | ✔️ | ✔️ +sign | ✔️ | ✔️ | ✔️ +split-pdfs | ✔️ | ✔️ | ✔️ +add-image | ✔️ | ✔️ | ✔️ +file-to-pdf | | ✔️ | ✔️ +pdf-to-html | | ✔️ | ✔️ +pdf-to-presentation | | ✔️ | ✔️ +pdf-to-text | | ✔️ | ✔️ +pdf-to-word | | ✔️ | ✔️ +pdf-to-xml | | ✔️ | ✔️ +repair | | ✔️ | ✔️ +xlsx-to-pdf | | ✔️ | ✔️ +compress-pdf | | | ✔️ +extract-image-scans | | | ✔️ +ocr-pdf | | | ✔️ +pdf-to-pdfa | | | ✔️ +remove-blanks | | | ✔️ diff --git a/groups.md b/groups.md deleted file mode 100644 index 93fc359a..00000000 --- a/groups.md +++ /dev/null @@ -1,38 +0,0 @@ -Operation | PageOps | Convert | Security | Other | CLI | Python | OpenCV | LibreOffice | OCRmyPDF | Java | Javascript ---------------------|---------|---------|----------|-------|------|--------|--------|-------------|--------- |-------- |----------- -remove-pages | X | | | | | | | | | X | -merge-pdfs | X | | | | | | | | | X | -split-pdfs | X | | | | | | | | | X | -pdf-organizer | X | | | | | | | | | X | X -rotate-pdf | X | | | | | | | | | X | -multi-page-layout | X | | | | | | | | | X | -scale-pages | X | | | | | | | | | X | -pdf-to-img | | X | | | | | | | | X | -img-to-pdf | | X | | | | | | | | X | -pdf-to-pdfa | | X | | | X | | | | X | | -file-to-pdf | | X | | | X | | | X | | | -xlsx-to-pdf | | X | | | X | | | X | | | -pdf-to-word | | X | | | X | | | X | | | -pdf-to-presentation | | X | | | X | | | X | | | -pdf-to-text | | X | | | X | | | X | | | -pdf-to-html | | X | | | X | | | X | | | -pdf-to-xml | | X | | | X | | | X | | | -add-password | | | X | | | | | | | X | -remove-password | | | X | | | | | | | X | -change-permissions | | | X | | | | | | | X | -add-watermark | | | X | | | | | | | X | -cert-sign | | | X | | | | | | | X | -ocr-pdf | | | | X | X | | | | X | | -add-image | | | | X | | | | | | X | -compress-pdf | | | | X | X | | | | X -extract-images | | | | X | | | | | | X | -change-metadata | | | | X | | | | | | X | -extract-image-scans | | | | X | X | X | X | | | | -sign | | | | X | | | | | | | X -flatten | | | | X | | | | | | | -repair | | | | X | X | | | X | | | -remove-blanks | | | | X | X | X | X | | | | -compare | | | | X | | | | | | | X - - - diff --git a/src/main/resources/static/js/downloader.js b/src/main/resources/static/js/downloader.js index 117d441c..d5a8c34f 100644 --- a/src/main/resources/static/js/downloader.js +++ b/src/main/resources/static/js/downloader.js @@ -17,15 +17,20 @@ $(document).ready(function() { const override = $('#override').val() || ''; const originalButtonText = $('#submitBtn').text(); $('#submitBtn').text('Processing...'); - + console.log(override); try { + console.log("2"); if(remoteCall === true) { + console.log("3"); if (override === 'multi' || (!multiple && files.length > 1) && override !== 'single' ) { + console.log("3"); await submitMultiPdfForm(url, files); } else { + console.log("4"); await handleSingleDownload(url, formData); } } + console.log("5"); $('#submitBtn').text(originalButtonText); } catch (error) { handleDownloadError(error); @@ -37,7 +42,7 @@ $(document).ready(function() { -async function handleSingleDownload(url, formData, isMulti = false) { +async function handleSingleDownload(url, formData, isMulti = false , isZip = false) { try { const response = await fetch(url, { method: 'POST', body: formData }); const contentType = response.headers.get('content-type'); @@ -54,11 +59,10 @@ async function handleSingleDownload(url, formData, isMulti = false) { let filename = getFilenameFromContentDisposition(contentDisposition); const blob = await response.blob(); - if (contentType.includes('application/pdf') || contentType.includes('image/')) { - return handleResponse(blob, filename, !isMulti); + return handleResponse(blob, filename, !isMulti, isZip); } else { - return handleResponse(blob, filename); + return handleResponse(blob, filename, false, isZip); } } catch (error) { console.error('Error in handleSingleDownload:', error); @@ -95,21 +99,27 @@ async function handleJsonResponse(response) { } -async function handleResponse(blob, filename, considerViewOptions = false) { +async function handleResponse(blob, filename, considerViewOptions = false, isZip = false) { if (!blob) return; const downloadOption = localStorage.getItem('downloadOption'); + console.log("handleResponse 1"); if (considerViewOptions) { if (downloadOption === 'sameWindow') { + console.log("handleResponse 2"); const url = URL.createObjectURL(blob); window.location.href = url; return; } else if (downloadOption === 'newWindow') { + console.log("handleResponse 3"); const url = URL.createObjectURL(blob); window.open(url, '_blank'); return; - } + } } - downloadFile(blob, filename); + if(!isZip){ + downloadFile(blob, filename); + } + console.log("handleResponse 5"); return { filename, blob }; } @@ -126,6 +136,7 @@ function downloadFile(blob, filename) { return; } + console.log("downloadFile 1"); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; @@ -176,12 +187,13 @@ async function submitMultiPdfForm(url, files) { } try { - const downloadDetails = await handleSingleDownload(url, fileFormData, true); + const downloadDetails = await handleSingleDownload(url, fileFormData, true, zipFiles); console.log(downloadDetails); if (zipFiles) { jszip.file(downloadDetails.filename, downloadDetails.blob); } else { - downloadFile(downloadDetails.blob, downloadDetails.filename); + console.log("downloadFile 198"); + //downloadFile(downloadDetails.blob, downloadDetails.filename); } updateProgressBar(progressBar, Array.from(files).length); } catch (error) { @@ -196,6 +208,7 @@ async function submitMultiPdfForm(url, files) { if (zipFiles) { try { const content = await jszip.generateAsync({ type: "blob" }); + console.log("downloadFile 213"); downloadFile(content, "files.zip"); } catch (error) { console.error('Error generating ZIP file: ' + error);