From 960af83f1158138fa8b3112b884dc7b20033d8bb Mon Sep 17 00:00:00 2001 From: farwill Date: Tue, 26 Dec 2023 14:30:18 +0800 Subject: [PATCH 01/12] Fix README.md typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d72c9859..ff362f5a 100644 --- a/README.md +++ b/README.md @@ -267,7 +267,7 @@ For API usage you must provide a header with 'X-API-Key' and the associated API - Fill forms mannual and automatic ### Q2: Why is my application downloading .htm files? -This is a issue caused commonly by your NGINX congifuration. The default file upload size for NGINX is 1MB, you need to add the following in your Nginx sites-available file. ``client_max_body_size SIZE;`` Where "SIZE" is 50M for example for 50MB files. +This is a issue caused commonly by your NGINX configuration. The default file upload size for NGINX is 1MB, you need to add the following in your Nginx sites-available file. ``client_max_body_size SIZE;`` Where "SIZE" is 50M for example for 50MB files. ### Q3: Why is my download timing out NGINX has timeout values by default so if you are running Stirling-PDF behind NGINX you may need to set a timeout value such as adding the config ``proxy_read_timeout 3600;`` From 4d3e442eccb4935a5f823c1dff183d57bda6fc01 Mon Sep 17 00:00:00 2001 From: sbplat <71648843+sbplat@users.noreply.github.com> Date: Tue, 26 Dec 2023 13:26:37 -0500 Subject: [PATCH 02/12] fix: add default value for the position in Add Page Numbers --- src/main/resources/templates/misc/add-page-numbers.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/templates/misc/add-page-numbers.html b/src/main/resources/templates/misc/add-page-numbers.html index 1ede15f8..8d8af86c 100644 --- a/src/main/resources/templates/misc/add-page-numbers.html +++ b/src/main/resources/templates/misc/add-page-numbers.html @@ -93,7 +93,7 @@ + max="9" value="8" required />
Date: Tue, 26 Dec 2023 13:31:33 -0500 Subject: [PATCH 03/12] fix: add selectedPosition style to the Add Page Number position selector default value --- src/main/resources/templates/misc/add-page-numbers.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/templates/misc/add-page-numbers.html b/src/main/resources/templates/misc/add-page-numbers.html index 8d8af86c..a9284126 100644 --- a/src/main/resources/templates/misc/add-page-numbers.html +++ b/src/main/resources/templates/misc/add-page-numbers.html @@ -87,7 +87,7 @@
5
6
7
-
8
+
8
9
From d79db6f3da82d43a1dd74f578a17ab043163b8bf Mon Sep 17 00:00:00 2001 From: albanobattistella <34811668+albanobattistella@users.noreply.github.com> Date: Wed, 27 Dec 2023 16:01:00 +0100 Subject: [PATCH 04/12] Update messages_it_IT.properties --- src/main/resources/messages_it_IT.properties | 78 ++++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/main/resources/messages_it_IT.properties b/src/main/resources/messages_it_IT.properties index 15827256..b301ff30 100644 --- a/src/main/resources/messages_it_IT.properties +++ b/src/main/resources/messages_it_IT.properties @@ -336,23 +336,23 @@ home.autoRedact.title=Redazione automatica home.autoRedact.desc=Redige automaticamente (oscura) il testo in un PDF in base al testo immesso showJS.tags=JS -home.tableExtraxt.title=PDF to CSV -home.tableExtraxt.desc=Extracts Tables from a PDF converting it to CSV -tableExtraxt.tags=CSV,Table Extraction,extract,convert +home.tableExtraxt.title=Da PDF a CSV +home.tableExtraxt.desc=Estrae tabelle da un PDF convertendolo in CSV +tableExtraxt.tags=CSV,Estrazione tabella,estrai,converti -home.autoSizeSplitPDF.title=Auto Split by Size/Count -home.autoSizeSplitPDF.desc=Split a single PDF into multiple documents based on size, page count, or document count -autoSizeSplitPDF.tags=pdf,split,document,organization +home.autoSizeSplitPDF.title=Divisione automatica per dimensione/numero +home.autoSizeSplitPDF.desc=Dividi un singolo PDF in più documenti in base alle dimensioni, al numero di pagine o al numero di documenti +autoSizeSplitPDF.tags=pdf,diviso,documento,organizzazione home.overlay-pdfs.title=Overlay PDFs home.overlay-pdfs.desc=Overlays PDFs on-top of another PDF overlay-pdfs.tags=Overlay -home.split-by-sections.title=Split PDF by Sections -home.split-by-sections.desc=Divide each page of a PDF into smaller horizontal and vertical sections -split-by-sections.tags=Section Split, Divide, Customize +home.split-by-sections.title=Dividi PDF per sezioni +home.split-by-sections.desc=Dividi ciascuna pagina di un PDF in sezioni orizzontali e verticali più piccole +split-by-sections.tags=Dividi sezione, dividi, personalizza ########################### # # @@ -692,10 +692,10 @@ split.submit=Dividi imageToPDF.title=Immagine a PDF imageToPDF.header=Immagine a PDF imageToPDF.submit=Converti -imageToPDF.selectLabel=Image Fit Options -imageToPDF.fillPage=Fill Page -imageToPDF.fitDocumentToImage=Fit Page to Image -imageToPDF.maintainAspectRatio=Maintain Aspect Ratios +imageToPDF.selectLabel=Opzioni di adattamento immagine +imageToPDF.fillPage=Riempi la pagina +imageToPDF.fitDocumentToImage=Adatta la pagina all'immagine +imageToPDF.maintainAspectRatio=Mantieni le proporzioni imageToPDF.selectText.2=Ruota automaticamente PDF imageToPDF.selectText.3=Logica multi-file (funziona solo se ci sono più immagini) imageToPDF.selectText.4=Unisci in un unico PDF @@ -845,41 +845,41 @@ PDFToXML.submit=Converti #PDFToCSV PDFToCSV.title=Da PDF a CSV PDFToCSV.header=Da PDF a CSV -PDFToCSV.prompt=Choose page to extract table +PDFToCSV.prompt=Scegli la pagina per estrarre la tabella PDFToCSV.submit=Estratto #split-by-size-or-count -split-by-size-or-count.header=Split PDF by Size or Count -split-by-size-or-count.type.label=Select Split Type -split-by-size-or-count.type.size=By Size -split-by-size-or-count.type.pageCount=By Page Count -split-by-size-or-count.type.docCount=By Document Count -split-by-size-or-count.value.label=Enter Value -split-by-size-or-count.value.placeholder=Enter size (e.g., 2MB or 3KB) or count (e.g., 5) -split-by-size-or-count.submit=Submit +split-by-size-or-count.header=Dividi il PDF per dimensione o numero +split-by-size-or-count.type.label=Seleziona il tipo di divisione +split-by-size-or-count.type.size=Per dimensione +split-by-size-or-count.type.pageCount=Per numero di pagine +split-by-size-or-count.type.docCount=Per numero di documento +split-by-size-or-count.value.label=Inserire il valore +split-by-size-or-count.value.placeholder=Inserisci la dimensione (ad esempio, 2 MB o 3 KB) o il numero (ad esempio, 5) +split-by-size-or-count.submit=Separa #overlay-pdfs -overlay-pdfs.header=Overlay PDF Files -overlay-pdfs.baseFile.label=Select Base PDF File -overlay-pdfs.overlayFiles.label=Select Overlay PDF Files -overlay-pdfs.mode.label=Select Overlay Mode -overlay-pdfs.mode.sequential=Sequential Overlay +overlay-pdfs.header=Invia file PDF in sovrapposizione +overlay-pdfs.baseFile.label=Seleziona File PDF di base +overlay-pdfs.overlayFiles.label=Seleziona sovrapposizione file PDF +overlay-pdfs.mode.label=Seleziona la modalità di sovrapposizione +overlay-pdfs.mode.sequential=Sovrapposizione sequenziale overlay-pdfs.mode.interleaved=Interleaved Overlay overlay-pdfs.mode.fixedRepeat=Fixed Repeat Overlay overlay-pdfs.counts.label=Overlay Counts (for Fixed Repeat Mode) -overlay-pdfs.counts.placeholder=Enter comma-separated counts (e.g., 2,3,1) -overlay-pdfs.position.label=Select Overlay Position -overlay-pdfs.position.foreground=Foreground -overlay-pdfs.position.background=Background -overlay-pdfs.submit=Submit +overlay-pdfs.counts.placeholder=Inserisci i numeri separati da virgole (ad esempio, 2,3,1) +overlay-pdfs.position.label=Seleziona posizione di sovrapposizione +overlay-pdfs.position.foreground=Primo piano +overlay-pdfs.position.background=Sfondo +overlay-pdfs.submit=Sovrapponi #split-by-sections -split-by-sections.title=Split PDF by Sections -split-by-sections.header=Split PDF into Sections -split-by-sections.horizontal.label=Horizontal Divisions -split-by-sections.vertical.label=Vertical Divisions -split-by-sections.horizontal.placeholder=Enter number of horizontal divisions -split-by-sections.vertical.placeholder=Enter number of vertical divisions -split-by-sections.submit=Split PDF +split-by-sections.title=Dividi PDF per sezioni +split-by-sections.header=Dividi il PDF in sezioni +split-by-sections.horizontal.label=Divisioni orizzontali +split-by-sections.vertical.label=Divisioni verticali +split-by-sections.horizontal.placeholder=Inserire il numero di divisioni orizzontali +split-by-sections.vertical.placeholder=Inserire il numero di divisioni verticlai +split-by-sections.submit=Dividi PDF From 78ac9231c5fe39c53273d75d9cdc4d44b34e03bf Mon Sep 17 00:00:00 2001 From: Ikko Eltociear Ashimine Date: Thu, 28 Dec 2023 00:34:30 +0900 Subject: [PATCH 05/12] Update README.md temporay -> temporary --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ff362f5a..351380ea 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This is a powerful locally hosted web based PDF manipulation tool using docker t Stirling PDF makes no outbound calls for any record keeping or tracking. -All files and PDFs are either purely client side, in server memory only during the execution of the task or within a temporay file only for execution of the task. +All files and PDFs are either purely client side, in server memory only during the execution of the task or within a temporary file only for execution of the task. Any file which has been downloaded by the user will have already been deleted from the server by that time. Feel free to request any features or bug fixes either in github issues or our [Discord](https://discord.gg/Cn8pWhQRxZ) From aa671b8bd6b29167253f9b4716af41a8bdccff83 Mon Sep 17 00:00:00 2001 From: manuelkamp <48356947+manuelkamp@users.noreply.github.com> Date: Wed, 27 Dec 2023 18:46:37 +0100 Subject: [PATCH 06/12] Update LocalRunGuide.md --- LocalRunGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LocalRunGuide.md b/LocalRunGuide.md index 782e8b69..9df7dd43 100644 --- a/LocalRunGuide.md +++ b/LocalRunGuide.md @@ -20,7 +20,7 @@ Install the following software, if not already installed: - Git -- Python 3 (with pip) +- Python 3.8 (with pip) - Make From c769a0298293be34b3f72c422eafa3c4d4f62f02 Mon Sep 17 00:00:00 2001 From: manuelkamp <48356947+manuelkamp@users.noreply.github.com> Date: Wed, 27 Dec 2023 18:51:51 +0100 Subject: [PATCH 07/12] Update LocalRunGuide.md Edited run via java, since on previous step we moved the jar-file to /opt/Stirling-PDF --- LocalRunGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LocalRunGuide.md b/LocalRunGuide.md index 782e8b69..b3841922 100644 --- a/LocalRunGuide.md +++ b/LocalRunGuide.md @@ -176,7 +176,7 @@ rpm -qa | grep tesseract-langpack | sed 's/tesseract-langpack-//g' ```bash ./gradlew bootRun or -java -jar build/libs/app.jar +java -jar /opt/Stirling-PDF/Stirling-PDF-*.jar ``` ### Step 8: Adding a Desktop icon From 7b44cf77d6cf92533dab9f5ff03708bbd12fc573 Mon Sep 17 00:00:00 2001 From: manuelkamp <48356947+manuelkamp@users.noreply.github.com> Date: Wed, 27 Dec 2023 18:54:55 +0100 Subject: [PATCH 08/12] Update LocalRunGuide.md Added "WeasyPrint" to pip3 install section --- LocalRunGuide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LocalRunGuide.md b/LocalRunGuide.md index 782e8b69..535384c5 100644 --- a/LocalRunGuide.md +++ b/LocalRunGuide.md @@ -95,14 +95,14 @@ For Debian-based systems, you can use the following command: ```bash sudo apt-get install -y libreoffice-writer libreoffice-calc libreoffice-impress unpaper ocrmypdf -pip3 install uno opencv-python-headless unoconv pngquant +pip3 install uno opencv-python-headless unoconv pngquant WeasyPrint ``` For Fedora: ```bash sudo dnf install -y libreoffice-writer libreoffice-calc libreoffice-impress unpaper ocrmypdf -pip3 install uno opencv-python-headless unoconv pngquant +pip3 install uno opencv-python-headless unoconv pngquant WeasyPrint ``` ### Step 4: Clone and Build Stirling-PDF From dfda474ba5e90bb09dc2213796f262d861367168 Mon Sep 17 00:00:00 2001 From: manuelkamp <48356947+manuelkamp@users.noreply.github.com> Date: Wed, 27 Dec 2023 19:30:28 +0100 Subject: [PATCH 09/12] Update LocalRunGuide.md Added option to set up Stirling-PDF as a service --- LocalRunGuide.md | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/LocalRunGuide.md b/LocalRunGuide.md index 315ee46c..7126969f 100644 --- a/LocalRunGuide.md +++ b/LocalRunGuide.md @@ -202,6 +202,57 @@ EOF Note: Currently the app will run in the background until manually closed. +### Optional: Run Stirling-PDF as a service + +Create a new file where we store our service settings and open it with nano editor: +``` +nano /etc/systemd/system/stirlingpdf.service +``` + +Paste this content, make sure to update the filename of the jar-file. Press Ctrl+S and Ctrl+X to save and exit the nano editor: +``` +[Unit] +Description=Stirling-PDF service +After=syslog.target network.target + +[Service] +SuccessExitStatus=143 + +User=root +Group=root + +Type=simple + +WorkingDirectory=/opt/Stirling-PDF +ExecStart=/usr/bin/java -jar Stirling-PDF-0.17.2.jar +ExecStop=/bin/kill -15 $MAINPID + +[Install] +WantedBy=multi-user.target +``` + +Notify systemd that it has to rebuild its internal service database (you have to run this command every time you make a change in the service file): +``` +sudo systemctl daemon-reload +``` + +Enable the service to tell the service to start it automatically: +``` +sudo systemctl enable stirlingpdf.service +``` + +See the status of the service: +``` +sudo systemctl status stirlingpdf.service +``` + +Manually start/stop/restart the service: +``` +sudo systemctl start stirlingpdf.service +sudo systemctl stop stirlingpdf.service +sudo systemctl restart stirlingpdf.service +``` + --- Remember to set the necessary environment variables before running the project if you want to customize the application the list can be seen in the main readme. From 54859ac3baede8293acdac1737dfe80fca5092ad Mon Sep 17 00:00:00 2001 From: manuelkamp <48356947+manuelkamp@users.noreply.github.com> Date: Wed, 27 Dec 2023 19:52:51 +0100 Subject: [PATCH 10/12] Update LocalRunGuide.md Improved optional service section regarding environment variables in a separate .env file --- LocalRunGuide.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/LocalRunGuide.md b/LocalRunGuide.md index 7126969f..c7eaca0b 100644 --- a/LocalRunGuide.md +++ b/LocalRunGuide.md @@ -204,6 +204,12 @@ Note: Currently the app will run in the background until manually closed. ### Optional: Run Stirling-PDF as a service +First create a .env file, where you can store environment variables: +``` +touch /opt/Stirling-PDF/.env +``` +In this file you can add all variables, one variable per line, as stated in the main readme (for example SYSTEM_DEFAULTLOCALE="de-DE"). + Create a new file where we store our service settings and open it with nano editor: ``` nano /etc/systemd/system/stirlingpdf.service @@ -223,6 +229,7 @@ Group=root Type=simple +EnvironmentFile=/opt/Stirling-PDF/.env WorkingDirectory=/opt/Stirling-PDF ExecStart=/usr/bin/java -jar Stirling-PDF-0.17.2.jar ExecStop=/bin/kill -15 $MAINPID From d01473aceb3728edaa57be5cefb736304fca2269 Mon Sep 17 00:00:00 2001 From: Muhammad Sani Ibrahim <87580367+Saneeitas@users.noreply.github.com> Date: Thu, 28 Dec 2023 01:27:25 +0100 Subject: [PATCH 11/12] Update README.md made the english more standard --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 351380ea..809590d7 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,9 @@ This is a powerful locally hosted web based PDF manipulation tool using docker t Stirling PDF makes no outbound calls for any record keeping or tracking. -All files and PDFs are either purely client side, in server memory only during the execution of the task or within a temporary file only for execution of the task. -Any file which has been downloaded by the user will have already been deleted from the server by that time. +All files and PDFs exist either exclusively on the client side, reside in server memory only during task execution, or temporarily reside in a file solely for the execution of the task. Any file downloaded by the user will have been deleted from the server by that point. -Feel free to request any features or bug fixes either in github issues or our [Discord](https://discord.gg/Cn8pWhQRxZ) +Please feel free to submit feature requests or report bugs either through GitHub issues or on our [Discord](https://discord.gg/Cn8pWhQRxZ) ![stirling-home](images/stirling-home.png) From b7f62a635d59697bedac3b3bb340fd795119e7b8 Mon Sep 17 00:00:00 2001 From: EmadEldin Osman Date: Thu, 28 Dec 2023 04:51:50 +0300 Subject: [PATCH 12/12] Optimized the code in detect-blank-pages.py Made use of Numpy arrays --- scripts/detect-blank-pages.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/scripts/detect-blank-pages.py b/scripts/detect-blank-pages.py index 474c2735..4ca724c2 100644 --- a/scripts/detect-blank-pages.py +++ b/scripts/detect-blank-pages.py @@ -1,10 +1,11 @@ import cv2 import sys import argparse +import numpy as np def is_blank_image(image_path, threshold=10, white_percent=99, white_value=255, blur_size=5): image = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE) - + if image is None: print(f"Error: Unable to read the image file: {image_path}") return False @@ -15,19 +16,11 @@ def is_blank_image(image_path, threshold=10, white_percent=99, white_value=255, _, thresholded_image = cv2.threshold(blurred_image, white_value - threshold, white_value, cv2.THRESH_BINARY) # Calculate the percentage of white pixels in the thresholded image - white_pixels = 0 - total_pixels = thresholded_image.size - for i in range(0, thresholded_image.shape[0], 2): - for j in range(0, thresholded_image.shape[1], 2): - if thresholded_image[i, j] == white_value: - white_pixels += 1 - white_pixel_percentage = (white_pixels / (i * thresholded_image.shape[1] + j + 1)) * 100 - if white_pixel_percentage < white_percent: - return False + white_pixels = np.sum(thresholded_image == white_value) + white_pixel_percentage = (white_pixels / thresholded_image.size) * 100 print(f"Page has white pixel percent of {white_pixel_percentage}") - return True - + return white_pixel_percentage >= white_percent if __name__ == "__main__": @@ -39,9 +32,6 @@ if __name__ == "__main__": blank = is_blank_image(args.image_path, args.threshold, args.white_percent) - if blank: - # Return code 1: The image is considered blank. - sys.exit(1) - else: - # Return code 0: The image is not considered blank. - sys.exit(0) + # Return code 1: The image is considered blank. + # Return code 0: The image is not considered blank. + sys.exit(int(blank))