From b043e666ae896b055764af12ddebd82bf3f1f651 Mon Sep 17 00:00:00 2001 From: Zoey Date: Sun, 31 Dec 2023 15:54:34 +0100 Subject: [PATCH 01/14] switch images to alpine Signed-off-by: Zoey --- Dockerfile | 33 ++++++++------------ Dockerfile-lite | 70 ++++++++++++++++++++----------------------- Dockerfile-ultra-lite | 39 ++++++++++++------------ DockerfileBase | 55 +++++++++++----------------------- HowToUseOCR.md | 6 ++-- LocalRunGuide.md | 2 +- README.md | 4 +-- scripts/init.sh | 12 +++++--- 8 files changed, 96 insertions(+), 125 deletions(-) diff --git a/Dockerfile b/Dockerfile index f0eb592c..63bbc6b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,37 +11,30 @@ ENV DOCKER_ENABLE_SECURITY=false \ # PUID=1000 \ # PGID=1000 \ # UMASK=022 \ - + +# Copy necessary files +COPY scripts /scripts +COPY pipeline /pipeline +COPY src/main/resources/static/fonts/*.ttf /usr/share/fonts/opentype/noto +COPY src/main/resources/static/fonts/*.otf /usr/share/fonts/opentype/noto +COPY build/libs/*.jar app.jar # Create user and group ##RUN groupadd -g $PGID stirlingpdfgroup && \ ## useradd -u $PUID -g stirlingpdfgroup -s /bin/sh stirlingpdfuser && \ -## mkdir -p $HOME && chown stirlingpdfuser:stirlingpdfgroup $HOME - +## mkdir -p $HOME && chown stirlingpdfuser:stirlingpdfgroup $HOME && \ # Set up necessary directories and permissions -RUN mkdir -p /scripts /usr/share/fonts/opentype/noto /usr/share/tesseract-ocr /configs /logs /customFiles /pipeline /pipeline/defaultWebUIConfigs /pipeline/watchedFolders /pipeline/finishedFolders +RUN mkdir /configs /logs /customFiles /pipeline/watchedFolders /pipeline/finishedFolders && \ ##&& \ ## chown -R stirlingpdfuser:stirlingpdfgroup /scripts /usr/share/fonts/opentype/noto /usr/share/tesseract-ocr /configs /customFiles && \ -## chown -R stirlingpdfuser:stirlingpdfgroup /usr/share/tesseract-ocr-original - -# Copy necessary files -COPY ./scripts/* /scripts/ -COPY ./pipeline/ /pipeline/ -COPY src/main/resources/static/fonts/*.ttf /usr/share/fonts/opentype/noto/ -COPY src/main/resources/static/fonts/*.otf /usr/share/fonts/opentype/noto/ -COPY build/libs/*.jar app.jar - +## chown -R stirlingpdfuser:stirlingpdfgroup /usr/share/tesseract-ocr-original && \ # Set font cache and permissions -RUN fc-cache -f -v && chmod +x /scripts/* - -##&& \ + fc-cache -f -v && \ + chmod +x /scripts/* ## chown stirlingpdfuser:stirlingpdfgroup /app.jar && \ ## chmod +x /scripts/init.sh -# Expose necessary ports -EXPOSE 8080 - # Set user and run command ##USER stirlingpdfuser -ENTRYPOINT ["/scripts/init.sh"] +ENTRYPOINT ["tini", "--", "/scripts/init.sh"] CMD ["java", "-Dfile.encoding=UTF-8", "-jar", "/app.jar"] diff --git a/Dockerfile-lite b/Dockerfile-lite index 054c7639..982a53e7 100644 --- a/Dockerfile-lite +++ b/Dockerfile-lite @@ -1,65 +1,59 @@ -# Build jbig2enc in a separate stage -FROM bellsoft/liberica-openjdk-debian:17 +# use alpine +FROM alpine:latest ARG VERSION_TAG -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - libreoffice-core \ - libreoffice-common \ - libreoffice-writer \ - libreoffice-calc \ - libreoffice-impress \ - unoconv && \ - rm -rf /var/lib/apt/lists/* - - # Set Environment Variables ENV DOCKER_ENABLE_SECURITY=false \ HOME=/home/stirlingpdfuser \ VERSION_TAG=$VERSION_TAG \ JAVA_TOOL_OPTIONS="$JAVA_TOOL_OPTIONS -XX:MaxRAMPercentage=75" -# PUID=1000 \ +# PUID=1000 \ # PGID=1000 \ # UMASK=022 \ +# Copy necessary files +COPY scripts/download-security-jar.sh /scripts/download-security-jar.sh +COPY scripts/init-without-ocr.sh /scripts/init-without-ocr.sh +COPY pipeline /pipeline +COPY src/main/resources/static/fonts/*.ttf /usr/share/fonts/opentype/noto +COPY src/main/resources/static/fonts/*.otf /usr/share/fonts/opentype/noto +COPY build/libs/*.jar app.jar + +RUN apk add --no-cache \ + ca-certificates \ + tzdata \ + tini \ + bash \ + curl \ + openjdk17-jre \ +# Doc conversion + libreoffice-common \ + libreoffice-writer \ + libreoffice-calc \ + libreoffice-impress \ +# python and pip + python3 && \ + wget https://bootstrap.pypa.io/get-pip.py -qO - | python3 - --break-system-packages --no-cache-dir --upgrade && \ +# uno unoconv and HTML + pip install --break-system-packages --no-cache-dir --upgrade uno unoconv WeasyPrint && \ # Create user and group #RUN groupadd -g $PGID stirlingpdfgroup && \ # useradd -u $PUID -g stirlingpdfgroup -s /bin/sh stirlingpdfuser && \ # mkdir -p $HOME && chown stirlingpdfuser:stirlingpdfgroup $HOME - # Set up necessary directories and permissions -RUN mkdir -p /scripts /usr/share/fonts/opentype/noto /configs /customFiles /logs /pipeline /pipeline/defaultWebUIConfigs /pipeline/watchedFolders /pipeline/finishedFolders - + mkdir /configs /logs /customFiles /pipeline/watchedFolders /pipeline/finishedFolders && \ # chown -R stirlingpdfuser:stirlingpdfgroup /usr/share/fonts/opentype/noto /configs /customFiles - -# Copy necessary files -COPY ./scripts/download-security-jar.sh /scripts/download-security-jar.sh -COPY ./scripts/init-without-ocr.sh /scripts/init-without-ocr.sh -COPY ./pipeline/ /pipeline/ -COPY src/main/resources/static/fonts/*.ttf /usr/share/fonts/opentype/noto/ -COPY src/main/resources/static/fonts/*.otf /usr/share/fonts/opentype/noto/ -COPY build/libs/*.jar app.jar - # Set font cache and permissions -RUN fc-cache -f -v && \ -chmod +x /scripts/init-without-ocr.sh && \ -chmod +x /scripts/download-security-jar.sh - - + fc-cache -f -v && \ + chmod +x /scripts/*.sh # chown stirlingpdfuser:stirlingpdfgroup /app.jar - - - -# Expose the application port -EXPOSE 8080 - # Set environment variables ENV ENDPOINTS_GROUPS_TO_REMOVE=Python,OpenCV,OCRmyPDF ENV DOCKER_ENABLE_SECURITY=false # Run the application #USER stirlingpdfuser -ENTRYPOINT ["/scripts/init-without-ocr.sh"] +ENTRYPOINT ["tini", "--", "/scripts/init-without-ocr.sh"] CMD ["java", "-Dfile.encoding=UTF-8", "-jar", "/app.jar"] diff --git a/Dockerfile-ultra-lite b/Dockerfile-ultra-lite index d77c1b94..38eca953 100644 --- a/Dockerfile-ultra-lite +++ b/Dockerfile-ultra-lite @@ -1,5 +1,5 @@ -# Build jbig2enc in a separate stage -FROM bellsoft/liberica-openjdk-alpine:17 +# use alpine +FROM alpine:latest ARG VERSION_TAG @@ -8,39 +8,38 @@ ENV DOCKER_ENABLE_SECURITY=false \ HOME=/home/stirlingpdfuser \ VERSION_TAG=$VERSION_TAG \ JAVA_TOOL_OPTIONS="$JAVA_TOOL_OPTIONS -XX:MaxRAMPercentage=75" -# PUID=1000 \ +# PUID=1000 \ # PGID=1000 \ # UMASK=022 \ +# Copy necessary files +COPY scripts/download-security-jar.sh /scripts/download-security-jar.sh +COPY scripts/init-without-ocr.sh /scripts/init-without-ocr.sh +COPY pipeline /pipeline +COPY build/libs/*.jar app.jar + # Create user and group using Alpine's addgroup and adduser #RUN addgroup -g $PGID stirlingpdfgroup && \ # adduser -u $PUID -G stirlingpdfgroup -s /bin/sh -D stirlingpdfuser && \ # mkdir -p $HOME && chown stirlingpdfuser:stirlingpdfgroup $HOME - # Set up necessary directories and permissions #RUN mkdir -p /scripts /configs /customFiles && \ -# chown -R stirlingpdfuser:stirlingpdfgroup /scripts /configs /customFiles /logs /pipeline /pipeline/defaultWebUIConfigs /pipeline/watchedFolders /pipeline/finishedFolders - -RUN mkdir -p /scripts /usr/share/fonts/opentype/noto /configs /customFiles -COPY ./scripts/download-security-jar.sh /scripts/download-security-jar.sh -COPY ./scripts/init-without-ocr.sh /scripts/init-without-ocr.sh -COPY ./pipeline/ /pipeline/ -COPY build/libs/*.jar app.jar - +# chown -R stirlingpdfuser:stirlingpdfgroup /scripts /configs /customFiles /logs /pipeline /pipeline/defaultWebUIConfigs /pipeline/watchedFolders /pipeline/finishedFolders +RUN mkdir /configs /logs /customFiles && \ # Set font cache and permissions #RUN chown stirlingpdfuser:stirlingpdfgroup /app.jar - -RUN chmod +x /scripts/init-without-ocr.sh && \ -chmod +x /scripts/download-security-jar.sh && \ -apk add --no-cache curl - -# Expose the application port -EXPOSE 8080 + chmod +x /scripts/*.sh && \ + apk add --no-cache \ + ca-certificates \ + tzdata \ + tini \ + bash \ + curl # Set environment variables ENV ENDPOINTS_GROUPS_TO_REMOVE=CLI -ENTRYPOINT ["/scripts/init-without-ocr.sh"] +ENTRYPOINT ["tini", "--", "/scripts/init-without-ocr.sh"] # Run the application CMD ["java", "-Dfile.encoding=UTF-8", "-jar", "/app.jar"] diff --git a/DockerfileBase b/DockerfileBase index b37050c7..06832347 100644 --- a/DockerfileBase +++ b/DockerfileBase @@ -1,43 +1,24 @@ # Main stage -FROM ubuntu:latest AS base - - +FROM alpine:3.19.0 # JDK for app -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - openjdk-17-jre && \ - rm -rf /var/lib/apt/lists/* - +RUN apk add --no-cache \ + ca-certificates \ + tzdata \ + tini \ + bash \ + curl \ + openjdk17-jre \ # Doc conversion -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - libreoffice-core \ - libreoffice-common \ - libreoffice-writer \ - libreoffice-calc \ - libreoffice-impress \ - python3-uno \ - curl \ - unoconv && \ - rm -rf /var/lib/apt/lists/* - - + libreoffice \ # OCR MY PDF (unpaper for descew and other advanced featues) -RUN apt-get update && apt-get install -y --no-install-recommends software-properties-common gnupg2 && \ -add-apt-repository ppa:alex-p/tesseract-ocr5 && apt install -y --no-install-recommends tesseract-ocr && \ -apt-get update && \ - apt-get install -y --no-install-recommends \ - ghostscript \ - python3-pip \ ocrmypdf \ - unpaper && \ - rm -rf /var/lib/apt/lists/* && \ - mv /usr/share/tesseract-ocr /usr/share/tesseract-ocr-original && \ - pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir --upgrade ocrmypdf && \ - pip install --no-cache-dir --upgrade pillow==10.0.1 reportlab==3.6.13 wheel==0.38.1 setuptools==65.5.1 pyjwt==2.4.0 cryptography==39.0.1 - - -#CV and HTML -RUN pip install --no-cache-dir opencv-python-headless WeasyPrint + tesseract-ocr-data-eng \ +# CV + py3-opencv \ +# python3/pip + python3 && \ + wget https://bootstrap.pypa.io/get-pip.py -qO - | python3 - --break-system-packages --no-cache-dir --upgrade && \ +# uno unoconv and HTML + pip install --break-system-packages --no-cache-dir --upgrade unoconv WeasyPrint && \ + mv /usr/share/tessdata /usr/share/tessdata-original diff --git a/HowToUseOCR.md b/HowToUseOCR.md index d83d0fd2..8fdf8fe4 100644 --- a/HowToUseOCR.md +++ b/HowToUseOCR.md @@ -21,7 +21,7 @@ Depending on your requirements, you can choose the appropriate language pack for ### Installing Language Packs 1. Download the desired language pack(s) by selecting the `.traineddata` file(s) for the language(s) you need. -2. Place the `.traineddata` files in the Tesseract tessdata directory: `/usr/share/tesseract-ocr/5/tessdata` (Debian) or `/usr/share/tesseract/tessdata` (Fedora) +2. Place the `.traineddata` files in the Tesseract tessdata directory: `/usr/share/tessdata` # DO NOT REMOVE EXISTING ENG.TRAINEDDATA, IT'S REQUIRED. @@ -37,14 +37,14 @@ services: your_service_name: image: your_docker_image_name volumes: - - /location/of/trainingData:/usr/share/tesseract-ocr/5/tessdata + - /location/of/trainingData:/usr/share/tessdata ``` #### Docker run Add the following to your existing docker run command ```bash --v /location/of/trainingData:/usr/share/tesseract-ocr/5/tessdata +-v /location/of/trainingData:/usr/share/tessdata ``` #### Non-Docker diff --git a/LocalRunGuide.md b/LocalRunGuide.md index 824c1ae7..75a53b80 100644 --- a/LocalRunGuide.md +++ b/LocalRunGuide.md @@ -139,7 +139,7 @@ Easiest is to use the langpacks provided by your repositories. Skip the other st Manual: 1. Download the desired language pack(s) by selecting the `.traineddata` file(s) for the language(s) you need. -2. Place the `.traineddata` files in the Tesseract tessdata directory: `/usr/share/tesseract-ocr/5/tessdata` +2. Place the `.traineddata` files in the Tesseract tessdata directory: `/usr/share/tessdata` 3. Please view [OCRmyPDF install guide](https://ocrmypdf.readthedocs.io/en/latest/installation.html) for more info. **IMPORTANT:** DO NOT REMOVE EXISTING `eng.traineddata`, IT'S REQUIRED. diff --git a/README.md b/README.md index e8814b80..5876a7e2 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ Docker Run ```bash docker run -d \ -p 8080:8080 \ - -v /location/of/trainingData:/usr/share/tesseract-ocr/5/tessdata \ + -v /location/of/trainingData:/usr/share/tessdata \ -v /location/of/extraConfigs:/configs \ -v /location/of/logs:/logs \ -e DOCKER_ENABLE_SECURITY=false \ @@ -131,7 +131,7 @@ services: ports: - '8080:8080' volumes: - - /location/of/trainingData:/usr/share/tesseract-ocr/5/tessdata #Required for extra OCR languages + - /location/of/trainingData:/usr/share/tessdata #Required for extra OCR languages - /location/of/extraConfigs:/configs # - /location/of/customFiles:/customFiles/ # - /location/of/logs:/logs/ diff --git a/scripts/init.sh b/scripts/init.sh index 8f1f96db..7f5b19f0 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -3,10 +3,14 @@ # Copy the original tesseract-ocr files to the volume directory without overwriting existing files echo "Copying original files without overwriting existing files" mkdir -p /usr/share/tesseract-ocr -cp -rn /usr/share/tesseract-ocr-original/* /usr/share/tesseract-ocr +cp -rn /usr/share/tesseract-ocr-original/* /usr/share/tesseract-ocr -if [ -d /usr/share/tesseract-ocr/4.00/tessdata ]; then - cp -r /usr/share/tesseract-ocr/4.00/tessdata/* /usr/share/tesseract-ocr/5/tessdata/ || true; +if [ -d /usr/share/tesseract-ocr/4.00/tessdata ]; then + cp -r /usr/share/tesseract-ocr/4.00/tessdata/* /usr/share/tessdata || true; +fi + +if [ -d /usr/share/tesseract-ocr/5/tessdata ]; then + cp -r /usr/share/tesseract-ocr/5/tessdata/* /usr/share/tessdata || true; fi # Check if TESSERACT_LANGS environment variable is set and is not empty @@ -23,4 +27,4 @@ fi /scripts/download-security-jar.sh # Run the main command -exec "$@" \ No newline at end of file +exec "$@" From aaaf3ffe34290febc582f3ac4ab02adeaec3af4a Mon Sep 17 00:00:00 2001 From: Zoey Date: Sun, 31 Dec 2023 17:14:55 +0100 Subject: [PATCH 02/14] fix some things --- Dockerfile-lite | 9 +++------ Dockerfile-ultra-lite | 5 +++-- scripts/init.sh | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Dockerfile-lite b/Dockerfile-lite index 982a53e7..e4a36ec4 100644 --- a/Dockerfile-lite +++ b/Dockerfile-lite @@ -1,5 +1,5 @@ # use alpine -FROM alpine:latest +FROM alpine:3.19.0 ARG VERSION_TAG @@ -28,15 +28,12 @@ RUN apk add --no-cache \ curl \ openjdk17-jre \ # Doc conversion - libreoffice-common \ - libreoffice-writer \ - libreoffice-calc \ - libreoffice-impress \ + libreoffice \ # python and pip python3 && \ wget https://bootstrap.pypa.io/get-pip.py -qO - | python3 - --break-system-packages --no-cache-dir --upgrade && \ # uno unoconv and HTML - pip install --break-system-packages --no-cache-dir --upgrade uno unoconv WeasyPrint && \ + pip install --break-system-packages --no-cache-dir --upgrade unoconv WeasyPrint && \ # Create user and group #RUN groupadd -g $PGID stirlingpdfgroup && \ # useradd -u $PUID -g stirlingpdfgroup -s /bin/sh stirlingpdfuser && \ diff --git a/Dockerfile-ultra-lite b/Dockerfile-ultra-lite index 38eca953..f6c73df0 100644 --- a/Dockerfile-ultra-lite +++ b/Dockerfile-ultra-lite @@ -1,5 +1,5 @@ # use alpine -FROM alpine:latest +FROM alpine:3.19.0 ARG VERSION_TAG @@ -34,7 +34,8 @@ RUN mkdir /configs /logs /customFiles && \ tzdata \ tini \ bash \ - curl + curl \ + openjdk17-jre # Set environment variables ENV ENDPOINTS_GROUPS_TO_REMOVE=CLI diff --git a/scripts/init.sh b/scripts/init.sh index 7f5b19f0..ea8fd359 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -2,8 +2,8 @@ # Copy the original tesseract-ocr files to the volume directory without overwriting existing files echo "Copying original files without overwriting existing files" -mkdir -p /usr/share/tesseract-ocr -cp -rn /usr/share/tesseract-ocr-original/* /usr/share/tesseract-ocr +mkdir -p /usr/share/tessdata +cp -rn /usr/share/tessdata-original/* /usr/share/tessdata if [ -d /usr/share/tesseract-ocr/4.00/tessdata ]; then cp -r /usr/share/tesseract-ocr/4.00/tessdata/* /usr/share/tessdata || true; From 5afcbdbc8b94962b5cbcab633d06e0f4e4751a8a Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 10 Jan 2024 22:56:30 +0100 Subject: [PATCH 03/14] use patched libreoffice version --- Dockerfile-lite | 5 +++-- DockerfileBase | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile-lite b/Dockerfile-lite index e4a36ec4..7784d303 100644 --- a/Dockerfile-lite +++ b/Dockerfile-lite @@ -26,10 +26,11 @@ RUN apk add --no-cache \ tini \ bash \ curl \ - openjdk17-jre \ + openjdk17-jre && \ # Doc conversion - libreoffice \ + apk add --no-cache libreoffice --repository http://dl-cdn.alpinelinux.org/alpine/edge/community && \ # python and pip + apk add --no-cache \ python3 && \ wget https://bootstrap.pypa.io/get-pip.py -qO - | python3 - --break-system-packages --no-cache-dir --upgrade && \ # uno unoconv and HTML diff --git a/DockerfileBase b/DockerfileBase index 06832347..fec16f9b 100644 --- a/DockerfileBase +++ b/DockerfileBase @@ -8,10 +8,11 @@ RUN apk add --no-cache \ tini \ bash \ curl \ - openjdk17-jre \ + openjdk17-jre && \ # Doc conversion - libreoffice \ + apk add --no-cache libreoffice --repository http://dl-cdn.alpinelinux.org/alpine/edge/community && \ # OCR MY PDF (unpaper for descew and other advanced featues) + apk add --no-cache \ ocrmypdf \ tesseract-ocr-data-eng \ # CV From e560028097f648434731af1a74b8deb1451ff7a8 Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 31 Jan 2024 20:57:34 +0100 Subject: [PATCH 04/14] Update Dockerfile-lite --- Dockerfile-lite | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile-lite b/Dockerfile-lite index 7784d303..1f41ccd6 100644 --- a/Dockerfile-lite +++ b/Dockerfile-lite @@ -48,7 +48,7 @@ RUN apk add --no-cache \ # chown stirlingpdfuser:stirlingpdfgroup /app.jar # Set environment variables -ENV ENDPOINTS_GROUPS_TO_REMOVE=Python,OpenCV,OCRmyPDF +ENV ENDPOINTS_GROUPS_TO_REMOVE=OpenCV,OCRmyPDF ENV DOCKER_ENABLE_SECURITY=false # Run the application From 3debc1b0dfc35cad2e494385c07b636ffa49f5d3 Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 31 Jan 2024 20:59:07 +0100 Subject: [PATCH 05/14] add @testing (1/3) --- DockerfileBase | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DockerfileBase b/DockerfileBase index fec16f9b..fd34ddf9 100644 --- a/DockerfileBase +++ b/DockerfileBase @@ -22,4 +22,7 @@ RUN apk add --no-cache \ wget https://bootstrap.pypa.io/get-pip.py -qO - | python3 - --break-system-packages --no-cache-dir --upgrade && \ # uno unoconv and HTML pip install --break-system-packages --no-cache-dir --upgrade unoconv WeasyPrint && \ - mv /usr/share/tessdata /usr/share/tessdata-original + mv /usr/share/tessdata /usr/share/tessdata-original && \ + echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /etc/apk/repositories && \ + echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/community" | tee -a /etc/apk/repositories && \ + echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" | tee -a /etc/apk/repositories From bb08a632960003dc50b7391c6c679f82da1a127f Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 31 Jan 2024 20:59:22 +0100 Subject: [PATCH 06/14] add @testing (2/3) --- Dockerfile-ultra-lite | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile-ultra-lite b/Dockerfile-ultra-lite index f6c73df0..e01debb0 100644 --- a/Dockerfile-ultra-lite +++ b/Dockerfile-ultra-lite @@ -35,7 +35,10 @@ RUN mkdir /configs /logs /customFiles && \ tini \ bash \ curl \ - openjdk17-jre + openjdk17-jre && \ + echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /etc/apk/repositories && \ + echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/community" | tee -a /etc/apk/repositories && \ + echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" | tee -a /etc/apk/repositories # Set environment variables ENV ENDPOINTS_GROUPS_TO_REMOVE=CLI From d190ae0cf3fc622333227495e6d9fa31bd8228a2 Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 31 Jan 2024 20:59:43 +0100 Subject: [PATCH 07/14] add @testing (3/3) --- Dockerfile-lite | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile-lite b/Dockerfile-lite index 1f41ccd6..979d97de 100644 --- a/Dockerfile-lite +++ b/Dockerfile-lite @@ -44,7 +44,10 @@ RUN apk add --no-cache \ # chown -R stirlingpdfuser:stirlingpdfgroup /usr/share/fonts/opentype/noto /configs /customFiles # Set font cache and permissions fc-cache -f -v && \ - chmod +x /scripts/*.sh + chmod +x /scripts/*.sh && \ + echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /etc/apk/repositories && \ + echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/community" | tee -a /etc/apk/repositories && \ + echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" | tee -a /etc/apk/repositories # chown stirlingpdfuser:stirlingpdfgroup /app.jar # Set environment variables From 296f265391c951b818c58ad053006adea83711c2 Mon Sep 17 00:00:00 2001 From: Stirling-PDF-Bot Date: Tue, 6 Feb 2024 08:39:13 +0000 Subject: [PATCH 08/14] Update 3rd Party Licenses --- .../resources/static/3rdPartyLicenses.json | 92 +++++++++++-------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/src/main/resources/static/3rdPartyLicenses.json b/src/main/resources/static/3rdPartyLicenses.json index 699be591..c03dd84c 100644 --- a/src/main/resources/static/3rdPartyLicenses.json +++ b/src/main/resources/static/3rdPartyLicenses.json @@ -95,6 +95,13 @@ "moduleLicense": "MPL 2.0", "moduleLicenseUrl": "https://www.mozilla.org/en-US/MPL/2.0/" }, + { + "moduleName": "com.martiansoftware:jsap", + "moduleUrl": "http://www.martiansoftware.com/jsap/", + "moduleVersion": "2.1", + "moduleLicense": "LGPL", + "moduleLicenseUrl": "http://www.martiansoftware.com/jsap/license.html" + }, { "moduleName": "com.opencsv:opencsv", "moduleUrl": "http://opencsv.sf.net", @@ -204,31 +211,38 @@ "moduleLicense": "The Apache Software License, Version 2.0", "moduleLicenseUrl": "/LICENSE.txt" }, + { + "moduleName": "io.github.pixee:java-security-toolkit", + "moduleUrl": "https://github.com/pixee/java-security-toolkit", + "moduleVersion": "1.1.2", + "moduleLicense": "MIT License", + "moduleLicenseUrl": "http://www.opensource.org/licenses/mit-license.php" + }, { "moduleName": "io.micrometer:micrometer-commons", "moduleUrl": "https://github.com/micrometer-metrics/micrometer", - "moduleVersion": "1.12.1", + "moduleVersion": "1.12.2", "moduleLicense": "The Apache Software License, Version 2.0", "moduleLicenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.txt" }, { "moduleName": "io.micrometer:micrometer-core", "moduleUrl": "https://github.com/micrometer-metrics/micrometer", - "moduleVersion": "1.12.1", + "moduleVersion": "1.12.2", "moduleLicense": "The Apache Software License, Version 2.0", "moduleLicenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.txt" }, { "moduleName": "io.micrometer:micrometer-jakarta9", "moduleUrl": "https://github.com/micrometer-metrics/micrometer", - "moduleVersion": "1.12.1", + "moduleVersion": "1.12.2", "moduleLicense": "The Apache Software License, Version 2.0", "moduleLicenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.txt" }, { "moduleName": "io.micrometer:micrometer-observation", "moduleUrl": "https://github.com/micrometer-metrics/micrometer", - "moduleVersion": "1.12.1", + "moduleVersion": "1.12.2", "moduleLicense": "The Apache Software License, Version 2.0", "moduleLicenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.txt" }, @@ -310,7 +324,7 @@ }, { "moduleName": "net.bytebuddy:byte-buddy", - "moduleVersion": "1.14.10", + "moduleVersion": "1.14.11", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0.txt" }, @@ -385,21 +399,21 @@ { "moduleName": "org.apache.tomcat.embed:tomcat-embed-core", "moduleUrl": "https://tomcat.apache.org/", - "moduleVersion": "10.1.17", + "moduleVersion": "10.1.18", "moduleLicense": "Eclipse Public License - v 2.0", "moduleLicenseUrl": "https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt" }, { "moduleName": "org.apache.tomcat.embed:tomcat-embed-el", "moduleUrl": "https://tomcat.apache.org/", - "moduleVersion": "10.1.17", + "moduleVersion": "10.1.18", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.txt" }, { "moduleName": "org.apache.tomcat.embed:tomcat-embed-websocket", "moduleUrl": "https://tomcat.apache.org/", - "moduleVersion": "10.1.17", + "moduleVersion": "10.1.18", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.txt" }, @@ -582,14 +596,14 @@ { "moduleName": "org.slf4j:jul-to-slf4j", "moduleUrl": "http://www.slf4j.org", - "moduleVersion": "2.0.9", + "moduleVersion": "2.0.11", "moduleLicense": "MIT License", "moduleLicenseUrl": "http://www.opensource.org/licenses/mit-license.php" }, { "moduleName": "org.slf4j:slf4j-api", "moduleUrl": "http://www.slf4j.org", - "moduleVersion": "2.0.9", + "moduleVersion": "2.0.11", "moduleLicense": "MIT License", "moduleLicenseUrl": "http://www.opensource.org/licenses/mit-license.php" }, @@ -614,126 +628,126 @@ { "moduleName": "org.springframework.boot:spring-boot", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-actuator", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-actuator-autoconfigure", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-autoconfigure", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-devtools", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-starter", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-starter-actuator", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-starter-aop", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-starter-data-jpa", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-starter-jdbc", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-starter-json", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-starter-logging", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-starter-security", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-starter-thymeleaf", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-starter-tomcat", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.boot:spring-boot-starter-web", "moduleUrl": "https://spring.io/projects/spring-boot", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.data:spring-data-commons", "moduleUrl": "https://spring.io/projects/spring-data", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework.data:spring-data-jpa", "moduleUrl": "https://projects.spring.io/spring-data-jpa", - "moduleVersion": "3.2.1", + "moduleVersion": "3.2.2", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, @@ -768,77 +782,77 @@ { "moduleName": "org.springframework:spring-aop", "moduleUrl": "https://github.com/spring-projects/spring-framework", - "moduleVersion": "6.1.2", + "moduleVersion": "6.1.3", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework:spring-aspects", "moduleUrl": "https://github.com/spring-projects/spring-framework", - "moduleVersion": "6.1.2", + "moduleVersion": "6.1.3", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework:spring-beans", "moduleUrl": "https://github.com/spring-projects/spring-framework", - "moduleVersion": "6.1.2", + "moduleVersion": "6.1.3", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework:spring-context", "moduleUrl": "https://github.com/spring-projects/spring-framework", - "moduleVersion": "6.1.2", + "moduleVersion": "6.1.3", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework:spring-core", "moduleUrl": "https://github.com/spring-projects/spring-framework", - "moduleVersion": "6.1.2", + "moduleVersion": "6.1.3", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework:spring-expression", "moduleUrl": "https://github.com/spring-projects/spring-framework", - "moduleVersion": "6.1.2", + "moduleVersion": "6.1.3", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework:spring-jcl", "moduleUrl": "https://github.com/spring-projects/spring-framework", - "moduleVersion": "6.1.2", + "moduleVersion": "6.1.3", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework:spring-jdbc", "moduleUrl": "https://github.com/spring-projects/spring-framework", - "moduleVersion": "6.1.2", + "moduleVersion": "6.1.3", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework:spring-orm", "moduleUrl": "https://github.com/spring-projects/spring-framework", - "moduleVersion": "6.1.2", + "moduleVersion": "6.1.3", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework:spring-tx", "moduleUrl": "https://github.com/spring-projects/spring-framework", - "moduleVersion": "6.1.2", + "moduleVersion": "6.1.3", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, { "moduleName": "org.springframework:spring-web", "moduleUrl": "https://github.com/spring-projects/spring-framework", - "moduleVersion": "6.1.2", + "moduleVersion": "6.1.3", "moduleLicense": "Apache License, Version 2.0", "moduleLicenseUrl": "https://www.apache.org/licenses/LICENSE-2.0" }, From 3f932ebec9799f0981809ca0560b07d4d16dc18e Mon Sep 17 00:00:00 2001 From: NeilJared Date: Tue, 6 Feb 2024 10:03:55 +0100 Subject: [PATCH 09/14] Update messages_es_ES.properties Updated es_ES translation (100%) --- src/main/resources/messages_es_ES.properties | 104 +++++++++---------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/src/main/resources/messages_es_ES.properties b/src/main/resources/messages_es_ES.properties index 538cc776..37bc5a06 100644 --- a/src/main/resources/messages_es_ES.properties +++ b/src/main/resources/messages_es_ES.properties @@ -42,9 +42,9 @@ red=Rojo green=Verde blue=Azul custom=Personalizado... -WorkInProgess=Work in progress, May not work or be buggy, Please report any ploblems! -poweredBy=Powered by -yes=Yes +WorkInProgess=Tarea en progreso, puede no funcionar o ralentizarse; ¡por favor, informe de cualquier problema! +poweredBy=Desarrollado por +yes=Sí no=No changedCredsMessage=Se cambiaron las credenciales! notAuthenticatedMessage=Usuario no autentificado. @@ -56,24 +56,24 @@ usernameExistsMessage=El nuevo nombre de usuario está en uso. ############### # Pipeline # ############### -pipeline.header=Pipeline Menu (Alpha) -pipeline.uploadButton=Upload Custom -pipeline.configureButton=Configure -pipeline.defaultOption=Custom -pipeline.submitButton=Submit +pipeline.header=Menu Pipeline (Alfa) +pipeline.uploadButton=Cargar personalización +pipeline.configureButton=Configurar +pipeline.defaultOption=Personalizar +pipeline.submitButton=Enviar ###################### # Pipeline Options # ###################### -pipelineOptions.header=Pipeline Configuration -pipelineOptions.pipelineNameLabel=Pipeline Name -pipelineOptions.saveSettings=Save Operation Settings -pipelineOptions.pipelineNamePrompt=Enter pipeline name here -pipelineOptions.selectOperation=Select Operation -pipelineOptions.addOperationButton=Add operation +pipelineOptions.header=Configuración Pipeline +pipelineOptions.pipelineNameLabel=Nombre del Pipeline +pipelineOptions.saveSettings=Guardar configuración de la oiperación +pipelineOptions.pipelineNamePrompt=Introduzca aquí el nombre del pipeline +pipelineOptions.selectOperation=Seleccione la operación +pipelineOptions.addOperationButton=Añadir operación pipelineOptions.pipelineHeader=Pipeline: -pipelineOptions.saveButton=Download -pipelineOptions.validateButton=Validate +pipelineOptions.saveButton=Descargar +pipelineOptions.validateButton=Validar @@ -466,37 +466,37 @@ HTMLToPDF.header=HTML a PDF HTMLToPDF.help=Acepta archivos HTML y ZIPs conteniendo los html/css/imágenes, etc, requeridas HTMLToPDF.submit=Convertir HTMLToPDF.credit=Utiliza WeasyPrint -HTMLToPDF.zoom=Zoom level for displaying the website. -HTMLToPDF.pageWidth=Width of the page in centimeters. (Blank to default) -HTMLToPDF.pageHeight=Height of the page in centimeters. (Blank to default) -HTMLToPDF.marginTop=Top margin of the page in millimeters. (Blank to default) -HTMLToPDF.marginBottom=Bottom margin of the page in millimeters. (Blank to default) -HTMLToPDF.marginLeft=Left margin of the page in millimeters. (Blank to default) -HTMLToPDF.marginRight=Right margin of the page in millimeters. (Blank to default) -HTMLToPDF.printBackground=Render the background of websites. -HTMLToPDF.defaultHeader=Enable Default Header (Name and page number) -HTMLToPDF.cssMediaType=Change the CSS media type of the page. -HTMLToPDF.none=None -HTMLToPDF.print=Print -HTMLToPDF.screen=Screen +HTMLToPDF.zoom=Nivel de zoom para mostrar la página web. +HTMLToPDF.pageWidth=Ancho de la página en centímetros. (Dejar en blanco por defecto) +HTMLToPDF.pageHeight=Alto de la página en centímetros. (Dejar en blanco por defecto) +HTMLToPDF.marginTop=Margen superior de la página en milímetros. (Dejar en blanco por defecto) +HTMLToPDF.marginBottom=Margen inferior de la página en milímetros. (Dejar en blanco por defecto) +HTMLToPDF.marginLeft=Margen izquierdo de la página en milímetros. (Dejar en blanco por defecto) +HTMLToPDF.marginRight=Margen derecho de la página en milímetros. (Dejar en blanco por defecto) +HTMLToPDF.printBackground=Renderizar el fondo de las páginas web. +HTMLToPDF.defaultHeader=Habilitar encabezado predeterminado (Nombre y número de página) +HTMLToPDF.cssMediaType=Cambiar el tipo de medio CSS de la página. +HTMLToPDF.none=Ninguno +HTMLToPDF.print=Imprimir +HTMLToPDF.screen=Pantalla #AddStampRequest -AddStampRequest.header=Stamp PDF -AddStampRequest.title=Stamp PDF -AddStampRequest.stampType=Stamp Type -AddStampRequest.stampText=Stamp Text -AddStampRequest.stampImage=Stamp Image -AddStampRequest.alphabet=Alphabet -AddStampRequest.fontSize=Font/Image Size -AddStampRequest.rotation=Rotation -AddStampRequest.opacity=Opacity -AddStampRequest.position=Position -AddStampRequest.overrideX=Override X Coordinate -AddStampRequest.overrideY=Override Y Coordinate -AddStampRequest.customMargin=Custom Margin -AddStampRequest.customColor=Custom Text Color -AddStampRequest.submit=Submit +AddStampRequest.header=Sellar PDF +AddStampRequest.title=Sellar PDF +AddStampRequest.stampType=Tipo de sello +AddStampRequest.stampText=Texto del sello +AddStampRequest.stampImage=Imagen de sello +AddStampRequest.alphabet=Alfabeto +AddStampRequest.fontSize=Tamaño de fuente/imagen +AddStampRequest.rotation=Rotación +AddStampRequest.opacity=Opacidad +AddStampRequest.position=Posición +AddStampRequest.overrideX=Forzar coordenada X +AddStampRequest.overrideY=Forzar coordenada Y +AddStampRequest.customMargin=Personalizar margen +AddStampRequest.customColor=Personalizar color de texto +AddStampRequest.submit=Enviar #sanitizePDF sanitizePDF.title=Desinfectar archivo PDF @@ -584,11 +584,11 @@ scalePages.submit=Entregar certSign.title=Firma con certificado certSign.header=Firmar un PDF con su certificado (en desarrollo) certSign.selectPDF=Seleccione un archivo PDF para firmar: -certSign.jksNote=Note: If your certificate type is not listed below, please convert it to a Java Keystore (.jks) file using the keytool command line tool. Then, choose the .jks file option below. +certSign.jksNote=Nota: si el tipo de certificado no está enla lista de abajo, por favor conviértalo a un archivo almacén de claves de Java Java KeyStore (.jks) utilizando la herramienta línea de comandos. Posteriormente, seleccione en el listado de abajo la opción archivo .jks. certSign.selectKey=Seleccione su archivo de clave privada (formato PKCS#8, podría ser .pem o .der): certSign.selectCert=Seleccione su archivo de certificado (formato X.509, podría ser .pem o .der): certSign.selectP12=Seleccione su archivo de almacén de claves PKCS#12 (.p12 o .pfx) (Opcional, si se proporciona, debe contener su clave privada y certificado): -certSign.selectJKS=Select Your Java Keystore File (.jks or .keystore): +certSign.selectJKS=Seleccione su archivo de almacén de claves Java KeyStore (.jks or .keystore): certSign.certType=Tipo de certificado certSign.password=Introduzca su almacén de claves o contraseña de clave privada (si corresponde): certSign.showSig=Mostrar firma @@ -961,11 +961,11 @@ split-by-sections.submit=Dividir PDF #licenses -licenses.nav=Licenses -licenses.title=3rd Party Licenses -licenses.header=3rd Party Licenses -licenses.module=Module -licenses.version=Version -licenses.license=License +licenses.nav=Licencias +licenses.title=Licencias de terceros +licenses.header=Licencias de terceros +licenses.module=Módulo +licenses.version=Versión +licenses.license=Licencia From aa2ad33c1d3e61c4f073a1865debcb3b05e376bc Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 7 Feb 2024 06:15:32 +0100 Subject: [PATCH 10/14] fix libreoffice install --- DockerfileBase | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DockerfileBase b/DockerfileBase index fd34ddf9..44e1a582 100644 --- a/DockerfileBase +++ b/DockerfileBase @@ -2,17 +2,19 @@ FROM alpine:3.19.0 # JDK for app -RUN apk add --no-cache \ +RUN echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /etc/apk/repositories && \ + echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/community" | tee -a /etc/apk/repositories && \ + echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" | tee -a /etc/apk/repositories && \ + apk add --no-cache \ ca-certificates \ tzdata \ tini \ bash \ curl \ - openjdk17-jre && \ + openjdk17-jre \ # Doc conversion - apk add --no-cache libreoffice --repository http://dl-cdn.alpinelinux.org/alpine/edge/community && \ + libreoffice@testing \ # OCR MY PDF (unpaper for descew and other advanced featues) - apk add --no-cache \ ocrmypdf \ tesseract-ocr-data-eng \ # CV @@ -22,7 +24,5 @@ RUN apk add --no-cache \ wget https://bootstrap.pypa.io/get-pip.py -qO - | python3 - --break-system-packages --no-cache-dir --upgrade && \ # uno unoconv and HTML pip install --break-system-packages --no-cache-dir --upgrade unoconv WeasyPrint && \ - mv /usr/share/tessdata /usr/share/tessdata-original && \ - echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /etc/apk/repositories && \ - echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/community" | tee -a /etc/apk/repositories && \ - echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" | tee -a /etc/apk/repositories + mv /usr/share/tessdata /usr/share/tessdata-original + From 4af58118c932b1cc6f0931d863995f77baed52e6 Mon Sep 17 00:00:00 2001 From: sbplat <71648843+sbplat@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:40:33 -0500 Subject: [PATCH 11/14] fix: use the same margins for x and y in the stamp feature --- .../software/SPDF/LibreOfficeListener.java | 3 +- .../software/SPDF/SPdfApplication.java | 3 +- .../api/MultiPageLayoutController.java | 5 +- .../controller/api/PdfOverlayController.java | 5 +- .../api/RearrangePagesPDFController.java | 9 ++- .../controller/api/RotationController.java | 6 +- .../controller/api/ScalePagesController.java | 5 +- .../controller/api/SplitPDFController.java | 6 +- .../api/SplitPdfBySectionsController.java | 6 +- .../api/SplitPdfBySizeController.java | 6 +- .../ConvertBookToPDFController.java | 2 +- .../api/converters/ConvertHtmlToPDF.java | 2 +- .../converters/ConvertImgPDFController.java | 6 +- .../api/converters/ConvertMarkdownToPdf.java | 2 +- .../converters/ConvertOfficeController.java | 5 +- .../ConvertPDFToBookController.java | 5 +- .../api/converters/ConvertPDFToPDFA.java | 6 +- .../api/filters/FilterController.java | 2 +- .../api/misc/AutoRenameController.java | 5 +- .../api/misc/AutoSplitPdfController.java | 6 +- .../api/misc/BlankPageController.java | 5 +- .../api/misc/CompressController.java | 6 +- .../api/misc/ExtractImagesController.java | 6 +- .../api/misc/FakeScanControllerWIP.java | 6 +- .../api/misc/MetadataController.java | 6 +- .../controller/api/misc/OCRController.java | 10 ++- .../api/misc/OverlayImageController.java | 6 +- .../api/misc/PageNumbersController.java | 5 +- .../controller/api/misc/RepairController.java | 6 +- .../controller/api/misc/ShowJavascript.java | 5 +- .../controller/api/misc/StampController.java | 71 ++++++++++--------- .../api/pipeline/PipelineProcessor.java | 5 +- .../api/security/CertSignController.java | 6 +- .../api/security/PasswordController.java | 12 ++-- .../api/security/RedactController.java | 5 +- .../api/security/SanitizeController.java | 5 +- .../api/security/WatermarkController.java | 6 +- .../software/SPDF/utils/FileToPdf.java | 6 +- .../software/SPDF/utils/GeneralUtils.java | 9 +-- .../software/SPDF/utils/PDFToFile.java | 3 +- .../software/SPDF/utils/PdfUtils.java | 3 +- .../software/SPDF/utils/ProcessExecutor.java | 13 +++- .../software/SPDF/utils/WebResponseUtils.java | 3 +- 43 files changed, 187 insertions(+), 116 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/LibreOfficeListener.java b/src/main/java/stirling/software/SPDF/LibreOfficeListener.java index d8196dcd..96c4d270 100644 --- a/src/main/java/stirling/software/SPDF/LibreOfficeListener.java +++ b/src/main/java/stirling/software/SPDF/LibreOfficeListener.java @@ -1,12 +1,13 @@ package stirling.software.SPDF; -import io.github.pixee.security.SystemCommand; import java.io.IOException; import java.net.InetSocketAddress; import java.net.Socket; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import io.github.pixee.security.SystemCommand; + public class LibreOfficeListener { private static final long ACTIVITY_TIMEOUT = 20 * 60 * 1000; // 20 minutes diff --git a/src/main/java/stirling/software/SPDF/SPdfApplication.java b/src/main/java/stirling/software/SPDF/SPdfApplication.java index f37dfb6e..62cbfe10 100644 --- a/src/main/java/stirling/software/SPDF/SPdfApplication.java +++ b/src/main/java/stirling/software/SPDF/SPdfApplication.java @@ -1,6 +1,5 @@ package stirling.software.SPDF; -import io.github.pixee.security.SystemCommand; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Collections; @@ -11,6 +10,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.core.env.Environment; import org.springframework.scheduling.annotation.EnableScheduling; +import io.github.pixee.security.SystemCommand; + import jakarta.annotation.PostConstruct; import stirling.software.SPDF.config.ConfigInitializer; import stirling.software.SPDF.utils.GeneralUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java index b4949a58..adc5424d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api; -import io.github.pixee.security.Filenames; import java.awt.Color; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -22,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -137,6 +137,7 @@ public class MultiPageLayoutController { byte[] result = baos.toByteArray(); return WebResponseUtils.bytesToWebResponse( result, - Filenames.toSimpleFileName(file.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_layoutChanged.pdf"); + Filenames.toSimpleFileName(file.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + + "_layoutChanged.pdf"); } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/PdfOverlayController.java b/src/main/java/stirling/software/SPDF/controller/api/PdfOverlayController.java index f9938a39..a6148d4a 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/PdfOverlayController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/PdfOverlayController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api; -import io.github.pixee.security.Filenames; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; @@ -21,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -77,7 +77,8 @@ public class PdfOverlayController { overlay.overlay(overlayGuide).save(outputStream); byte[] data = outputStream.toByteArray(); String outputFilename = - Filenames.toSimpleFileName(baseFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + Filenames.toSimpleFileName(baseFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + "_overlayed.pdf"; // Remove file extension and append .pdf return WebResponseUtils.bytesToWebResponse( diff --git a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java index 3074f9f8..88bdcd91 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api; -import io.github.pixee.security.Filenames; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -17,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -58,7 +58,9 @@ public class RearrangePagesPDFController { } return WebResponseUtils.pdfDocToWebResponse( document, - Filenames.toSimpleFileName(pdfFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_removed_pages.pdf"); + Filenames.toSimpleFileName(pdfFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + + "_removed_pages.pdf"); } private List removeFirst(int totalPages) { @@ -212,7 +214,8 @@ public class RearrangePagesPDFController { return WebResponseUtils.pdfDocToWebResponse( document, - Filenames.toSimpleFileName(pdfFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + Filenames.toSimpleFileName(pdfFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + "_rearranged.pdf"); } catch (IOException e) { logger.error("Failed rearranging documents", e); diff --git a/src/main/java/stirling/software/SPDF/controller/api/RotationController.java b/src/main/java/stirling/software/SPDF/controller/api/RotationController.java index 609e20f8..76f508d3 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RotationController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RotationController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api; -import io.github.pixee.security.Filenames; import java.io.IOException; import org.apache.pdfbox.Loader; @@ -16,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -50,6 +50,8 @@ public class RotationController { return WebResponseUtils.pdfDocToWebResponse( document, - Filenames.toSimpleFileName(pdfFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_rotated.pdf"); + Filenames.toSimpleFileName(pdfFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + + "_rotated.pdf"); } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java index 03994321..91cd012d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api; -import io.github.pixee.security.Filenames; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; @@ -23,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -113,6 +113,7 @@ public class ScalePagesController { return WebResponseUtils.bytesToWebResponse( baos.toByteArray(), - Filenames.toSimpleFileName(file.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_scaled.pdf"); + Filenames.toSimpleFileName(file.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + + "_scaled.pdf"); } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java index c218788a..44c87464 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api; -import io.github.pixee.security.Filenames; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.file.Files; @@ -24,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -84,7 +84,9 @@ public class SplitPDFController { Path zipFile = Files.createTempFile("split_documents", ".zip"); - String filename = Filenames.toSimpleFileName(file.getOriginalFilename()).replaceFirst("[.][^.]+$", ""); + String filename = + Filenames.toSimpleFileName(file.getOriginalFilename()) + .replaceFirst("[.][^.]+$", ""); try (ZipOutputStream zipOut = new ZipOutputStream(Files.newOutputStream(zipFile))) { // loop through the split documents and write them to the zip file for (int i = 0; i < splitDocumentsBoas.size(); i++) { diff --git a/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySectionsController.java b/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySectionsController.java index 2951a73e..3deb798e 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySectionsController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySectionsController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api; -import io.github.pixee.security.Filenames; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.file.Files; @@ -27,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -65,7 +65,9 @@ public class SplitPdfBySectionsController { sourceDocument.close(); Path zipFile = Files.createTempFile("split_documents", ".zip"); - String filename = Filenames.toSimpleFileName(file.getOriginalFilename()).replaceFirst("[.][^.]+$", ""); + String filename = + Filenames.toSimpleFileName(file.getOriginalFilename()) + .replaceFirst("[.][^.]+$", ""); byte[] data; try (ZipOutputStream zipOut = new ZipOutputStream(Files.newOutputStream(zipFile))) { diff --git a/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySizeController.java b/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySizeController.java index eb2cfa28..45d2dd38 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySizeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySizeController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api; -import io.github.pixee.security.Filenames; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.file.Files; @@ -21,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -121,7 +121,9 @@ public class SplitPdfBySizeController { sourceDocument.close(); Path zipFile = Files.createTempFile("split_documents", ".zip"); - String filename = Filenames.toSimpleFileName(file.getOriginalFilename()).replaceFirst("[.][^.]+$", ""); + String filename = + Filenames.toSimpleFileName(file.getOriginalFilename()) + .replaceFirst("[.][^.]+$", ""); byte[] data; try (ZipOutputStream zipOut = new ZipOutputStream(Files.newOutputStream(zipFile))) { diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertBookToPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertBookToPDFController.java index a266e871..3cbc783c 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertBookToPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertBookToPDFController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.converters; -import io.github.pixee.security.Filenames; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.ResponseEntity; @@ -10,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java index 2cf79992..189eebdf 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.converters; -import io.github.pixee.security.Filenames; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.ResponseEntity; @@ -10,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java index c131d883..86a70472 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.converters; -import io.github.pixee.security.Filenames; import java.io.IOException; import java.net.URLConnection; @@ -19,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -57,7 +57,9 @@ public class ConvertImgPDFController { // returns bytes for image boolean singleImage = "single".equals(singleOrMultiple); byte[] result = null; - String filename = Filenames.toSimpleFileName(file.getOriginalFilename()).replaceFirst("[.][^.]+$", ""); + String filename = + Filenames.toSimpleFileName(file.getOriginalFilename()) + .replaceFirst("[.][^.]+$", ""); try { result = PdfUtils.convertFromPdf( diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java index 39710ea0..050dd0fe 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.converters; -import io.github.pixee.security.Filenames; import java.util.List; import java.util.Map; @@ -20,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java index ce3d9fe9..c6740b5f 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.converters; -import io.github.pixee.security.Filenames; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -17,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -90,7 +90,8 @@ public class ConvertOfficeController { byte[] pdfByteArray = convertToPdf(inputFile); return WebResponseUtils.bytesToWebResponse( pdfByteArray, - Filenames.toSimpleFileName(inputFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + Filenames.toSimpleFileName(inputFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + "_convertedToPDF.pdf"); } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToBookController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToBookController.java index 9711fc5e..c9171305 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToBookController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToBookController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.converters; -import io.github.pixee.security.Filenames; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -16,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -93,7 +93,8 @@ public class ConvertPDFToBookController { } String outputFilename = - Filenames.toSimpleFileName(fileInput.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + Filenames.toSimpleFileName(fileInput.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + "." + outputFormat; // Remove file extension and append .pdf diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java index 5de8ee9a..41498413 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.converters; -import io.github.pixee.security.Filenames; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -13,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -64,7 +64,9 @@ public class ConvertPDFToPDFA { // Return the optimized PDF as a response String outputFilename = - Filenames.toSimpleFileName(inputFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_PDFA.pdf"; + Filenames.toSimpleFileName(inputFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + + "_PDFA.pdf"; return WebResponseUtils.bytesToWebResponse(pdfBytes, outputFilename); } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java b/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java index 6326cf19..9beaf413 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.filters; -import io.github.pixee.security.Filenames; import java.io.IOException; import org.apache.pdfbox.Loader; @@ -14,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java index 9000658c..2dc6c8a3 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.misc; -import io.github.pixee.security.Filenames; import java.io.IOException; import java.util.ArrayList; import java.util.Comparator; @@ -19,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -134,7 +134,8 @@ public class AutoRenameController { return WebResponseUtils.pdfDocToWebResponse(document, header + ".pdf"); } else { logger.info("File has no good title to be found"); - return WebResponseUtils.pdfDocToWebResponse(document, Filenames.toSimpleFileName(file.getOriginalFilename())); + return WebResponseUtils.pdfDocToWebResponse( + document, Filenames.toSimpleFileName(file.getOriginalFilename())); } } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java index da162d85..32f39c04 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.misc; -import io.github.pixee.security.Filenames; import java.awt.image.BufferedImage; import java.awt.image.DataBufferByte; import java.awt.image.DataBufferInt; @@ -32,6 +31,7 @@ import com.google.zxing.PlanarYUVLuminanceSource; import com.google.zxing.Result; import com.google.zxing.common.HybridBinarizer; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -98,7 +98,9 @@ public class AutoSplitPdfController { document.close(); Path zipFile = Files.createTempFile("split_documents", ".zip"); - String filename = Filenames.toSimpleFileName(file.getOriginalFilename()).replaceFirst("[.][^.]+$", ""); + String filename = + Filenames.toSimpleFileName(file.getOriginalFilename()) + .replaceFirst("[.][^.]+$", ""); byte[] data; try (ZipOutputStream zipOut = new ZipOutputStream(Files.newOutputStream(zipFile))) { diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java index 34664a3b..b414a35b 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.misc; -import io.github.pixee.security.Filenames; import java.awt.image.BufferedImage; import java.io.IOException; import java.nio.file.Files; @@ -28,6 +27,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -132,7 +132,8 @@ public class BlankPageController { return WebResponseUtils.pdfDocToWebResponse( document, - Filenames.toSimpleFileName(inputFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + Filenames.toSimpleFileName(inputFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + "_blanksRemoved.pdf"); } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java index c1b4a996..82a2c72f 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.misc; -import io.github.pixee.security.Filenames; import java.awt.Image; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; @@ -30,6 +29,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -265,7 +265,9 @@ public class CompressController { // Return the optimized PDF as a response String outputFilename = - Filenames.toSimpleFileName(inputFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_Optimized.pdf"; + Filenames.toSimpleFileName(inputFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + + "_Optimized.pdf"; return WebResponseUtils.bytesToWebResponse(pdfBytes, outputFilename); } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImagesController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImagesController.java index cb9071d8..3931e2df 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImagesController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImagesController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.misc; -import io.github.pixee.security.Filenames; import java.awt.Graphics2D; import java.awt.Image; import java.awt.image.BufferedImage; @@ -30,6 +29,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -67,7 +67,9 @@ public class ExtractImagesController { zos.setLevel(Deflater.BEST_COMPRESSION); int imageIndex = 1; - String filename = Filenames.toSimpleFileName(file.getOriginalFilename()).replaceFirst("[.][^.]+$", ""); + String filename = + Filenames.toSimpleFileName(file.getOriginalFilename()) + .replaceFirst("[.][^.]+$", ""); int pageNum = 0; Set processedImages = new HashSet<>(); // Iterate over each page diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/FakeScanControllerWIP.java b/src/main/java/stirling/software/SPDF/controller/api/misc/FakeScanControllerWIP.java index 8fb4af43..789bf17e 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/FakeScanControllerWIP.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/FakeScanControllerWIP.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.misc; -import io.github.pixee.security.Filenames; import java.awt.Color; import java.awt.geom.AffineTransform; import java.awt.image.AffineTransformOp; @@ -34,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -142,7 +142,9 @@ public class FakeScanControllerWIP { // Return the optimized PDF as a response String outputFilename = - Filenames.toSimpleFileName(inputFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_scanned.pdf"; + Filenames.toSimpleFileName(inputFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + + "_scanned.pdf"; return WebResponseUtils.boasToWebResponse(baos, outputFilename); } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java index 8e4ae664..fec07380 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.misc; -import io.github.pixee.security.Filenames; import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -19,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -165,6 +165,8 @@ public class MetadataController { document.setDocumentInformation(info); return WebResponseUtils.pdfDocToWebResponse( document, - Filenames.toSimpleFileName(pdfFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_metadata.pdf"); + Filenames.toSimpleFileName(pdfFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + + "_metadata.pdf"); } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java index 143ae1da..542e3c6d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.misc; -import io.github.pixee.security.Filenames; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -25,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -183,12 +183,16 @@ public class OCRController { // Return the OCR processed PDF as a response String outputFilename = - Filenames.toSimpleFileName(inputFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_OCR.pdf"; + Filenames.toSimpleFileName(inputFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + + "_OCR.pdf"; if (sidecar != null && sidecar) { // Create a zip file containing both the PDF and the text file String outputZipFilename = - Filenames.toSimpleFileName(inputFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_OCR.zip"; + Filenames.toSimpleFileName(inputFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + + "_OCR.zip"; Path tempZipFile = Files.createTempFile("output_", ".zip"); try (ZipOutputStream zipOut = diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java index 01da177d..c3fad457 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.misc; -import io.github.pixee.security.Filenames; import java.io.IOException; import org.slf4j.Logger; @@ -13,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -45,7 +45,9 @@ public class OverlayImageController { return WebResponseUtils.bytesToWebResponse( result, - Filenames.toSimpleFileName(pdfFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_overlayed.pdf"); + Filenames.toSimpleFileName(pdfFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + + "_overlayed.pdf"); } catch (IOException e) { logger.error("Failed to add image to PDF", e); return new ResponseEntity<>(HttpStatus.BAD_REQUEST); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java index cd99e9d0..337a9f48 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.misc; -import io.github.pixee.security.Filenames; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; @@ -22,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -146,7 +146,8 @@ public class PageNumbersController { return WebResponseUtils.bytesToWebResponse( baos.toByteArray(), - Filenames.toSimpleFileName(file.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_numbersAdded.pdf", + Filenames.toSimpleFileName(file.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + + "_numbersAdded.pdf", MediaType.APPLICATION_PDF); } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java index caaaed5c..85d4560c 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.misc; -import io.github.pixee.security.Filenames; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -16,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -66,7 +66,9 @@ public class RepairController { // Return the optimized PDF as a response String outputFilename = - Filenames.toSimpleFileName(inputFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_repaired.pdf"; + Filenames.toSimpleFileName(inputFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + + "_repaired.pdf"; return WebResponseUtils.bytesToWebResponse(pdfBytes, outputFilename); } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java index 0903a6e1..6accfb7a 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.misc; -import io.github.pixee.security.Filenames; import java.nio.charset.StandardCharsets; import java.util.Map; @@ -17,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -55,7 +55,8 @@ public class ShowJavascript { script += "// File: " - + Filenames.toSimpleFileName(inputFile.getOriginalFilename()) + + Filenames.toSimpleFileName( + inputFile.getOriginalFilename()) + ", Script: " + name + "\n" diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/StampController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/StampController.java index 52e8d970..99a5e2df 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/StampController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/StampController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.misc; -import io.github.pixee.security.Filenames; import java.awt.Color; import java.awt.image.BufferedImage; import java.io.File; @@ -33,6 +32,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -65,6 +65,7 @@ public class StampController { String customColor = request.getCustomColor(); float marginFactor; + switch (request.getCustomMargin().toLowerCase()) { case "small": marginFactor = 0.02f; @@ -78,7 +79,6 @@ public class StampController { case "x-large": marginFactor = 0.075f; break; - default: marginFactor = 0.035f; break; @@ -88,6 +88,9 @@ public class StampController { PDDocument document = Loader.loadPDF(pdfFile.getBytes()); for (PDPage page : document.getPages()) { + PDRectangle pageSize = page.getMediaBox(); + float margin = marginFactor * (pageSize.getWidth() + pageSize.getHeight()) / 2; + PDPageContentStream contentStream = new PDPageContentStream( document, page, PDPageContentStream.AppendMode.APPEND, true, true); @@ -108,7 +111,7 @@ public class StampController { alphabet, overrideX, overrideY, - marginFactor, + margin, customColor); } else if ("image".equalsIgnoreCase(watermarkType)) { addImageStamp( @@ -121,7 +124,7 @@ public class StampController { fontSize, overrideX, overrideY, - marginFactor); + margin); } contentStream.close(); @@ -129,7 +132,9 @@ public class StampController { return WebResponseUtils.pdfDocToWebResponse( document, - Filenames.toSimpleFileName(pdfFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_watermarked.pdf"); + Filenames.toSimpleFileName(pdfFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + + "_watermarked.pdf"); } private void addTextStamp( @@ -143,7 +148,7 @@ public class StampController { String alphabet, float overrideX, // X override float overrideY, - float marginFactor, + float margin, String colorString) // Y override throws IOException { String resourceDir = ""; @@ -205,14 +210,10 @@ public class StampController { } else { x = calculatePositionX( - pageSize, - position, - fontSize, - font, - fontSize, - watermarkText, - marginFactor); - y = calculatePositionY(pageSize, position, fontSize, marginFactor); + pageSize, position, fontSize, font, fontSize, watermarkText, margin); + y = + calculatePositionY( + pageSize, position, calculateTextCapHeight(font, fontSize), margin); } contentStream.beginText(); @@ -231,7 +232,7 @@ public class StampController { float fontSize, float overrideX, float overrideY, - float marginFactor) + float margin) throws IOException { // Load the watermark image @@ -257,10 +258,8 @@ public class StampController { x = overrideX; y = overrideY; } else { - x = - calculatePositionX( - pageSize, position, desiredPhysicalWidth, null, 0, null, marginFactor); - y = calculatePositionY(pageSize, position, fontSize, marginFactor); + x = calculatePositionX(pageSize, position, desiredPhysicalWidth, null, 0, null, margin); + y = calculatePositionY(pageSize, position, fontSize, margin); } contentStream.saveGraphicsState(); @@ -277,17 +276,31 @@ public class StampController { PDFont font, float fontSize, String text, - float marginFactor) + float margin) throws IOException { float actualWidth = (text != null) ? calculateTextWidth(text, font, fontSize) : contentWidth; switch (position % 3) { case 1: // Left - return pageSize.getLowerLeftX() + marginFactor * pageSize.getWidth(); + return pageSize.getLowerLeftX() + margin; case 2: // Center return (pageSize.getWidth() - actualWidth) / 2; case 0: // Right - return pageSize.getUpperRightX() - actualWidth - marginFactor * pageSize.getWidth(); + return pageSize.getUpperRightX() - actualWidth - margin; + default: + return 0; + } + } + + private float calculatePositionY( + PDRectangle pageSize, int position, float height, float margin) { + switch ((position - 1) / 3) { + case 0: // Top + return pageSize.getUpperRightY() - height - margin; + case 1: // Middle + return (pageSize.getHeight() - height) / 2; + case 2: // Bottom + return pageSize.getLowerLeftY() + margin; default: return 0; } @@ -297,17 +310,7 @@ public class StampController { return font.getStringWidth(text) / 1000 * fontSize; } - private float calculatePositionY( - PDRectangle pageSize, int position, float height, float marginFactor) { - switch ((position - 1) / 3) { - case 0: // Top - return pageSize.getUpperRightY() - height - marginFactor * pageSize.getHeight(); - case 1: // Middle - return (pageSize.getHeight() - height) / 2; - case 2: // Bottom - return pageSize.getLowerLeftY() + marginFactor * pageSize.getHeight(); - default: - return 0; - } + private float calculateTextCapHeight(PDFont font, float fontSize) { + return font.getFontDescriptor().getCapHeight() / 1000 * fontSize; } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineProcessor.java b/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineProcessor.java index c4e98bdb..c327cdd8 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineProcessor.java +++ b/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineProcessor.java @@ -1,7 +1,5 @@ package stirling.software.SPDF.controller.api.pipeline; -import io.github.pixee.security.Filenames; -import io.github.pixee.security.ZipSecurity; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -38,6 +36,9 @@ import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; +import io.github.pixee.security.ZipSecurity; + import jakarta.servlet.ServletContext; import stirling.software.SPDF.SPdfApplication; import stirling.software.SPDF.model.PipelineConfig; diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/CertSignController.java b/src/main/java/stirling/software/SPDF/controller/api/security/CertSignController.java index 658f68f3..d066bd9a 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/CertSignController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/CertSignController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.security; -import io.github.pixee.security.Filenames; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -43,6 +42,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -124,7 +124,9 @@ public class CertSignController { ByteArrayOutputStream baos = new ByteArrayOutputStream(); sign(pdf.getBytes(), baos, createSignature, name, location, reason); return WebResponseUtils.boasToWebResponse( - baos, Filenames.toSimpleFileName(pdf.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_signed.pdf"); + baos, + Filenames.toSimpleFileName(pdf.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + + "_signed.pdf"); } private static void sign( diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java b/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java index 328b753c..84c44933 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.security; -import io.github.pixee.security.Filenames; import java.io.IOException; import org.apache.pdfbox.Loader; @@ -16,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -44,7 +44,8 @@ public class PasswordController { document.setAllSecurityToBeRemoved(true); return WebResponseUtils.pdfDocToWebResponse( document, - Filenames.toSimpleFileName(fileInput.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + Filenames.toSimpleFileName(fileInput.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + "_password_removed.pdf"); } @@ -89,10 +90,13 @@ public class PasswordController { if ("".equals(ownerPassword) && "".equals(password)) return WebResponseUtils.pdfDocToWebResponse( document, - Filenames.toSimpleFileName(fileInput.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + Filenames.toSimpleFileName(fileInput.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + "_permissions.pdf"); return WebResponseUtils.pdfDocToWebResponse( document, - Filenames.toSimpleFileName(fileInput.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_passworded.pdf"); + Filenames.toSimpleFileName(fileInput.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + + "_passworded.pdf"); } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java b/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java index 82ff54dd..0f482647 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.security; -import io.github.pixee.security.Filenames; import java.awt.Color; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; @@ -26,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -105,7 +105,8 @@ public class RedactController { byte[] pdfContent = baos.toByteArray(); return WebResponseUtils.bytesToWebResponse( pdfContent, - Filenames.toSimpleFileName(file.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_redacted.pdf"); + Filenames.toSimpleFileName(file.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + + "_redacted.pdf"); } private void redactFoundText( diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java b/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java index bbcfeeaa..6dfbf044 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.security; -import io.github.pixee.security.Filenames; import java.io.IOException; import org.apache.pdfbox.Loader; @@ -29,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -77,7 +77,8 @@ public class SanitizeController { return WebResponseUtils.pdfDocToWebResponse( document, - Filenames.toSimpleFileName(inputFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + Filenames.toSimpleFileName(inputFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + "_sanitized.pdf"); } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java b/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java index 91a8a265..9506822c 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.security; -import io.github.pixee.security.Filenames; import java.awt.Color; import java.awt.image.BufferedImage; import java.io.File; @@ -32,6 +31,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -106,7 +106,9 @@ public class WatermarkController { return WebResponseUtils.pdfDocToWebResponse( document, - Filenames.toSimpleFileName(pdfFile.getOriginalFilename()).replaceFirst("[.][^.]+$", "") + "_watermarked.pdf"); + Filenames.toSimpleFileName(pdfFile.getOriginalFilename()) + .replaceFirst("[.][^.]+$", "") + + "_watermarked.pdf"); } private void addTextWatermark( diff --git a/src/main/java/stirling/software/SPDF/utils/FileToPdf.java b/src/main/java/stirling/software/SPDF/utils/FileToPdf.java index 09ce430c..90f7dbc3 100644 --- a/src/main/java/stirling/software/SPDF/utils/FileToPdf.java +++ b/src/main/java/stirling/software/SPDF/utils/FileToPdf.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.utils; -import io.github.pixee.security.ZipSecurity; import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -13,6 +12,8 @@ import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import io.github.pixee.security.ZipSecurity; + import stirling.software.SPDF.model.api.converters.HTMLToPdfRequest; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; @@ -145,7 +146,8 @@ public class FileToPdf { private static Path unzipAndGetMainHtml(byte[] fileBytes) throws IOException { Path tempDirectory = Files.createTempDirectory("unzipped_"); - try (ZipInputStream zipIn = ZipSecurity.createHardenedInputStream(new ByteArrayInputStream(fileBytes))) { + try (ZipInputStream zipIn = + ZipSecurity.createHardenedInputStream(new ByteArrayInputStream(fileBytes))) { ZipEntry entry = zipIn.getNextEntry(); while (entry != null) { Path filePath = tempDirectory.resolve(entry.getName()); diff --git a/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java b/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java index 1737b27e..7b1082b3 100644 --- a/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java +++ b/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java @@ -1,13 +1,10 @@ package stirling.software.SPDF.utils; -import io.github.pixee.security.HostValidator; -import io.github.pixee.security.Urls; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; -import java.net.URL; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; @@ -19,6 +16,9 @@ import java.util.List; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.HostValidator; +import io.github.pixee.security.Urls; + public class GeneralUtils { public static File convertMultipartFileToFile(MultipartFile multipartFile) throws IOException { @@ -59,7 +59,8 @@ public class GeneralUtils { public static boolean isValidURL(String urlStr) { try { - Urls.create(urlStr, Urls.HTTP_PROTOCOLS, HostValidator.DENY_COMMON_INFRASTRUCTURE_TARGETS); + Urls.create( + urlStr, Urls.HTTP_PROTOCOLS, HostValidator.DENY_COMMON_INFRASTRUCTURE_TARGETS); return true; } catch (MalformedURLException e) { return false; diff --git a/src/main/java/stirling/software/SPDF/utils/PDFToFile.java b/src/main/java/stirling/software/SPDF/utils/PDFToFile.java index 7afe6a49..43683be8 100644 --- a/src/main/java/stirling/software/SPDF/utils/PDFToFile.java +++ b/src/main/java/stirling/software/SPDF/utils/PDFToFile.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.utils; -import io.github.pixee.security.Filenames; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; @@ -21,6 +20,8 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; + import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; public class PDFToFile { diff --git a/src/main/java/stirling/software/SPDF/utils/PdfUtils.java b/src/main/java/stirling/software/SPDF/utils/PdfUtils.java index 748f8aad..77814340 100644 --- a/src/main/java/stirling/software/SPDF/utils/PdfUtils.java +++ b/src/main/java/stirling/software/SPDF/utils/PdfUtils.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.utils; -import io.github.pixee.security.Filenames; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.awt.image.RenderedImage; @@ -38,6 +37,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; + public class PdfUtils { private static final Logger logger = LoggerFactory.getLogger(PdfUtils.class); diff --git a/src/main/java/stirling/software/SPDF/utils/ProcessExecutor.java b/src/main/java/stirling/software/SPDF/utils/ProcessExecutor.java index f75367a7..2c81dce5 100644 --- a/src/main/java/stirling/software/SPDF/utils/ProcessExecutor.java +++ b/src/main/java/stirling/software/SPDF/utils/ProcessExecutor.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.utils; -import io.github.pixee.security.BoundedLineReader; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -17,6 +16,8 @@ import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import io.github.pixee.security.BoundedLineReader; + public class ProcessExecutor { private static final Logger logger = LoggerFactory.getLogger(ProcessExecutor.class); @@ -110,7 +111,10 @@ public class ProcessExecutor { process.getErrorStream(), StandardCharsets.UTF_8))) { String line; - while ((line = BoundedLineReader.readLine(errorReader, 5_000_000)) != null) { + while ((line = + BoundedLineReader.readLine( + errorReader, 5_000_000)) + != null) { errorLines.add(line); if (liveUpdates) logger.info(line); } @@ -131,7 +135,10 @@ public class ProcessExecutor { process.getInputStream(), StandardCharsets.UTF_8))) { String line; - while ((line = BoundedLineReader.readLine(outputReader, 5_000_000)) != null) { + while ((line = + BoundedLineReader.readLine( + outputReader, 5_000_000)) + != null) { outputLines.add(line); if (liveUpdates) logger.info(line); } diff --git a/src/main/java/stirling/software/SPDF/utils/WebResponseUtils.java b/src/main/java/stirling/software/SPDF/utils/WebResponseUtils.java index a85720e7..d148e65b 100644 --- a/src/main/java/stirling/software/SPDF/utils/WebResponseUtils.java +++ b/src/main/java/stirling/software/SPDF/utils/WebResponseUtils.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.utils; -import io.github.pixee.security.Filenames; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.URLEncoder; @@ -13,6 +12,8 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; +import io.github.pixee.security.Filenames; + public class WebResponseUtils { public static ResponseEntity boasToWebResponse( From 4e937a6024662242171431918401466bfb108c70 Mon Sep 17 00:00:00 2001 From: "pixeebot[bot]" <23113631+pixeebot@users.noreply.github.com> Date: Thu, 8 Feb 2024 02:46:39 +0000 Subject: [PATCH 12/14] Sanitized user-provided file names in HTTP multipart uploads --- .../software/SPDF/controller/api/misc/ShowJavascript.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java index 6accfb7a..e1355c30 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java @@ -68,7 +68,7 @@ public class ShowJavascript { if (script.isEmpty()) { script = - "PDF '" + inputFile.getOriginalFilename() + "' does not contain Javascript"; + "PDF '" + Filenames.toSimpleFileName(inputFile.getOriginalFilename()) + "' does not contain Javascript"; } return WebResponseUtils.bytesToWebResponse( From 41686883ee8b4899f0cd04b9d53acffa8a69ebd8 Mon Sep 17 00:00:00 2001 From: mannam <101550345+ManoharMannam@users.noreply.github.com> Date: Thu, 8 Feb 2024 21:03:57 +0530 Subject: [PATCH 13/14] Fixed remove pages un-handled exception with space in input #761 --- .../resources/templates/remove-pages.html | 68 ++++++++++--------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/src/main/resources/templates/remove-pages.html b/src/main/resources/templates/remove-pages.html index f86dc60e..ff4973f2 100644 --- a/src/main/resources/templates/remove-pages.html +++ b/src/main/resources/templates/remove-pages.html @@ -1,32 +1,38 @@ - - - - - - - -
-
-
-

-
-
-
-

- -
-
-
- - -
- -
-
-
-
-
-
-
- + + + + + + + + +
+
+
+

+
+
+
+

+ +
+
+
+ + +
+ +
+
+
+
+
+
+
+ + \ No newline at end of file From 2473f0d034e2e19f497f1e48e1aa3c59a44f9389 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Fri, 9 Feb 2024 23:22:16 +0000 Subject: [PATCH 14/14] Update build.gradle --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7025b2bd..2e8bbbdf 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ plugins { import com.github.jk1.license.render.* group = 'stirling.software' -version = '0.20.2' +version = '0.21.0' sourceCompatibility = '17' repositories {