From 631d3948bd7775725debd402259e8afb79b7d3b6 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Mon, 18 Dec 2023 14:52:18 +0000 Subject: [PATCH] fix for #531 plus seperated out some things --- Dockerfile-lite | 10 ++++++-- Dockerfile-ultra-lite | 8 ++++++- Version-groups.md | 5 ++++ build.gradle | 18 +++++++++++---- scripts/download-security-jar.sh | 19 +++++++++++++++ scripts/init-without-ocr.sh | 6 +++++ scripts/init.sh | 23 ++----------------- .../SPDF/config/EndpointConfiguration.java | 12 ++++++++++ src/main/resources/logback.xml | 4 ++-- 9 files changed, 74 insertions(+), 31 deletions(-) create mode 100644 scripts/download-security-jar.sh create mode 100644 scripts/init-without-ocr.sh diff --git a/Dockerfile-lite b/Dockerfile-lite index 4352aa52..9c77f400 100644 --- a/Dockerfile-lite +++ b/Dockerfile-lite @@ -30,12 +30,18 @@ RUN mkdir -p /scripts /usr/share/fonts/opentype/noto /configs /customFiles # 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 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 +RUN fc-cache -f -v && \ +chmod +x /scripts/init-without-ocr.sh && \ +chmod +x /scripts/download-security-jar.sh + + # chown stirlingpdfuser:stirlingpdfgroup /app.jar @@ -50,5 +56,5 @@ ENV DOCKER_ENABLE_SECURITY=false # Run the application #USER stirlingpdfuser -ENTRYPOINT ["/scripts/init.sh"] +ENTRYPOINT ["/scripts/init-without-ocr.sh"] CMD ["java", "-jar", "/app.jar"] diff --git a/Dockerfile-ultra-lite b/Dockerfile-ultra-lite index 966b0a8d..0e0eb406 100644 --- a/Dockerfile-ultra-lite +++ b/Dockerfile-ultra-lite @@ -19,19 +19,25 @@ ENV DOCKER_ENABLE_SECURITY=false \ # chown -R stirlingpdfuser:stirlingpdfgroup /scripts /configs /customFiles 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 build/libs/*.jar app.jar # 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 # Set environment variables ENV ENDPOINTS_GROUPS_TO_REMOVE=CLI -ENTRYPOINT ["/scripts/init.sh"] +ENTRYPOINT ["/scripts/init-without-ocr.sh"] # Run the application CMD ["java", "-jar", "/app.jar"] diff --git a/Version-groups.md b/Version-groups.md index 90020579..4fcbfe5a 100644 --- a/Version-groups.md +++ b/Version-groups.md @@ -19,6 +19,7 @@ add-image | ✔️ | ✔️ | ✔️ add-watermark | ✔️ | ✔️ | ✔️ adjust-contrast | ✔️ | ✔️ | ✔️ auto-split-pdf | ✔️ | ✔️ | ✔️ +auto-redact | ✔️ | ✔️ | ✔️ auto-rename | ✔️ | ✔️ | ✔️ cert-sign | ✔️ | ✔️ | ✔️ crop | ✔️ | ✔️ | ✔️ @@ -33,7 +34,9 @@ img-to-pdf | ✔️ | ✔️ | ✔️ markdown-to-pdf | ✔️ | ✔️ | ✔️ merge-pdfs | ✔️ | ✔️ | ✔️ multi-page-layout | ✔️ | ✔️ | ✔️ +overlay-pdf | ✔️ | ✔️ | ✔️ pdf-organizer | ✔️ | ✔️ | ✔️ +pdf-to-csv | ✔️ | ✔️ | ✔️ pdf-to-img | ✔️ | ✔️ | ✔️ pdf-to-single-page | ✔️ | ✔️ | ✔️ remove-pages | ✔️ | ✔️ | ✔️ @@ -43,6 +46,8 @@ sanitize-pdf | ✔️ | ✔️ | ✔️ scale-pages | ✔️ | ✔️ | ✔️ sign | ✔️ | ✔️ | ✔️ show-javascript | ✔️ | ✔️ | ✔️ +split-by-size-or-count | ✔️ | ✔️ | ✔️ +split-pdf-by-sections | ✔️ | ✔️ | ✔️ split-pdfs | ✔️ | ✔️ | ✔️ file-to-pdf | | ✔️ | ✔️ pdf-to-html | | ✔️ | ✔️ diff --git a/build.gradle b/build.gradle index 73b8a05f..dd626311 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { } group = 'stirling.software' -version = '0.17.1' +version = '0.17.2' sourceCompatibility = '17' repositories { @@ -32,7 +32,6 @@ sourceSets { } } - openApi { apiDocsUrl = "http://localhost:8080/v1/api-docs" outputDir = file("$projectDir") @@ -93,9 +92,18 @@ dependencies { //general PDF // https://mvnrepository.com/artifact/com.opencsv/opencsv - implementation group: 'com.opencsv', name: 'opencsv', version: '5.7.1' - implementation 'org.apache.pdfbox:pdfbox:2.0.29' - implementation 'org.apache.pdfbox:xmpbox:2.0.29' + implementation ('com.opencsv:opencsv:5.7.1') { + exclude group: 'commons-logging', module: 'commons-logging' + } + + implementation ('org.apache.pdfbox:pdfbox:2.0.29'){ + exclude group: 'commons-logging', module: 'commons-logging' + } + + implementation ('org.apache.pdfbox:xmpbox:2.0.29'){ + exclude group: 'commons-logging', module: 'commons-logging' + } + implementation 'org.bouncycastle:bcprov-jdk18on:1.77' implementation 'org.bouncycastle:bcpkix-jdk18on:1.77' implementation 'org.springframework.boot:spring-boot-starter-actuator' diff --git a/scripts/download-security-jar.sh b/scripts/download-security-jar.sh new file mode 100644 index 00000000..c0b710ad --- /dev/null +++ b/scripts/download-security-jar.sh @@ -0,0 +1,19 @@ +echo "Running Stirling PDF with DOCKER_ENABLE_SECURITY=${DOCKER_ENABLE_SECURITY} and VERSION_TAG=${VERSION_TAG}" +# Check for DOCKER_ENABLE_SECURITY and download the appropriate JAR if required +if [ "$DOCKER_ENABLE_SECURITY" = "true" ] && [ "$VERSION_TAG" != "alpha" ]; then + if [ ! -f app-security.jar ]; then + echo "Trying to download from: https://github.com/Frooodle/Stirling-PDF/releases/download/v$VERSION_TAG/Stirling-PDF-with-login.jar" + curl -L -o app-security.jar https://github.com/Frooodle/Stirling-PDF/releases/download/v$VERSION_TAG/Stirling-PDF-with-login.jar + + # If the first download attempt failed, try with the 'v' prefix + if [ $? -ne 0 ]; then + echo "Trying to download from: https://github.com/Frooodle/Stirling-PDF/releases/download/$VERSION_TAG/Stirling-PDF-with-login.jar" + curl -L -o app-security.jar https://github.com/Frooodle/Stirling-PDF/releases/download/$VERSION_TAG/Stirling-PDF-with-login.jar + fi + + if [ $? -eq 0 ]; then # checks if curl was successful + rm -f app.jar + ln -s app-security.jar app.jar + fi + fi +fi \ No newline at end of file diff --git a/scripts/init-without-ocr.sh b/scripts/init-without-ocr.sh new file mode 100644 index 00000000..2aced6a4 --- /dev/null +++ b/scripts/init-without-ocr.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +/scripts/download-security-jar.sh + +# Run the main command +exec "$@" \ No newline at end of file diff --git a/scripts/init.sh b/scripts/init.sh index 613406ef..8f1f96db 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -3,7 +3,7 @@ # 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; @@ -20,26 +20,7 @@ if [[ -n "$TESSERACT_LANGS" ]]; then done fi -echo "Running Stirling PDF with DOCKER_ENABLE_SECURITY=${DOCKER_ENABLE_SECURITY} and VERSION_TAG=${VERSION_TAG}" -# Check for DOCKER_ENABLE_SECURITY and download the appropriate JAR if required -if [ "$DOCKER_ENABLE_SECURITY" = "true" ] && [ "$VERSION_TAG" != "alpha" ]; then - if [ ! -f app-security.jar ]; then - echo "Trying to download from: https://github.com/Frooodle/Stirling-PDF/releases/download/v$VERSION_TAG/Stirling-PDF-with-login.jar" - curl -L -o app-security.jar https://github.com/Frooodle/Stirling-PDF/releases/download/v$VERSION_TAG/Stirling-PDF-with-login.jar - - # If the first download attempt failed, try with the 'v' prefix - if [ $? -ne 0 ]; then - echo "Trying to download from: https://github.com/Frooodle/Stirling-PDF/releases/download/$VERSION_TAG/Stirling-PDF-with-login.jar" - curl -L -o app-security.jar https://github.com/Frooodle/Stirling-PDF/releases/download/$VERSION_TAG/Stirling-PDF-with-login.jar - fi - - if [ $? -eq 0 ]; then # checks if curl was successful - rm -f app.jar - ln -s app-security.jar app.jar - fi - fi -fi - +/scripts/download-security-jar.sh # Run the main command exec "$@" \ No newline at end of file diff --git a/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java b/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java index ee17e0b9..042fb07a 100644 --- a/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java +++ b/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java @@ -81,6 +81,10 @@ public class EndpointConfiguration { addEndpointToGroup("PageOps", "auto-split-pdf"); addEndpointToGroup("PageOps", "extract-page"); addEndpointToGroup("PageOps", "pdf-to-single-page"); + addEndpointToGroup("PageOps", "split-by-size-or-count"); + addEndpointToGroup("PageOps", "overlay-pdf"); + addEndpointToGroup("PageOps", "split-pdf-by-sections"); + // Adding endpoints to "Convert" group addEndpointToGroup("Convert", "pdf-to-img"); @@ -96,6 +100,8 @@ public class EndpointConfiguration { addEndpointToGroup("Convert", "html-to-pdf"); addEndpointToGroup("Convert", "url-to-pdf"); addEndpointToGroup("Convert", "markdown-to-pdf"); + addEndpointToGroup("Convert", "pdf-to-csv"); + // Adding endpoints to "Security" group addEndpointToGroup("Security", "add-password"); @@ -104,6 +110,7 @@ public class EndpointConfiguration { addEndpointToGroup("Security", "add-watermark"); addEndpointToGroup("Security", "cert-sign"); addEndpointToGroup("Security", "sanitize-pdf"); + addEndpointToGroup("Security", "auto-redact"); // Adding endpoints to "Other" group @@ -197,6 +204,11 @@ public class EndpointConfiguration { addEndpointToGroup("Java", "pdf-to-single-page"); addEndpointToGroup("Java", "markdown-to-pdf"); addEndpointToGroup("Java", "show-javascript"); + addEndpointToGroup("Java", "auto-redact"); + addEndpointToGroup("Java", "pdf-to-csv"); + addEndpointToGroup("Java", "split-by-size-or-count"); + addEndpointToGroup("Java", "overlay-pdf"); + addEndpointToGroup("Java", "split-pdf-by-sections"); //Javascript addEndpointToGroup("Javascript", "pdf-organizer"); diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index f703600d..2d13578d 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -16,7 +16,7 @@ - auth-%d{MM-dd-yyyy}.log + logs/auth-%d{yyyy-MM-dd}.log 1 @@ -30,7 +30,7 @@ - info-%d{MM-dd-yyyy}.log + logs/info-%d{yyyy-MM-dd}.log 1