diff --git a/DockerfileBase b/DockerfileBase index d1c2df74..d95afa30 100644 --- a/DockerfileBase +++ b/DockerfileBase @@ -13,6 +13,16 @@ RUN apt-get update && \ pngquant \ unpaper \ ocrmypdf && \ + pip install --upgrade pip && \ + pip install --no-cache-dir \ + pillow==10.0.1 \ + lxml==4.6.5 \ + reportlab==3.6.13 \ + setuptools==65.5.1 \ + pikepdf==4.4.1 \ + wheel==0.38.1 \ + cryptography==39.0.1 \ + opencv-python-headless && \ rm -rf /var/lib/apt/lists/* && \ mkdir /usr/share/tesseract-ocr-original && \ cp -r /usr/share/tesseract-ocr/* /usr/share/tesseract-ocr-original && \ @@ -20,18 +30,45 @@ RUN apt-get update && \ # Python packages stage FROM base AS python-packages +# Install build tools and Python libraries RUN apt-get update && \ apt-get install -y --no-install-recommends \ build-essential \ libffi-dev \ libssl-dev \ zlib1g-dev \ - libjpeg-dev && \ - pip install --upgrade pip && \ - pip install --no-cache-dir \ - opencv-python-headless WeasyPrint && \ - rm -rf /var/lib/apt/lists/* + libjpeg-dev # Final stage: Copy necessary files from the previous stage FROM base -COPY --from=python-packages /usr/local /usr/local \ No newline at end of file +COPY --from=python-packages /usr/local /usr/local + + +# Install wkhtmltopdf +RUN apt-get update && \ + apt-get install -y \ + fontconfig \ + libfontconfig1 \ + libfreetype6 \ + libx11-6 \ + libxext6 \ + libxrender1 \ + xfonts-75dpi \ + wget \ + xfonts-base + +# Set a default value for TARGETARCH if it's not provided +ARG TARGETARCH=arm64 + +# Conditional statement to choose the correct wkhtmltopdf package based on architecture +RUN if [ "$TARGETARCH" = "amd64" ]; then \ + wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bullseye_amd64.deb; \ + elif [ "$TARGETARCH" = "arm64" ]; then \ + wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bullseye_arm64.deb; \ + else \ + wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bullseye_amd64.deb; \ + fi && \ + dpkg -i wkhtmltox_0.12.6.1-3.bullseye_$TARGETARCH.deb && \ + rm wkhtmltox_0.12.6.1-3.bullseye_$TARGETARCH.deb && \ + rm -rf /var/lib/apt/lists/* + \ No newline at end of file diff --git a/build.gradle b/build.gradle index a0cdea0c..69f458f7 100644 --- a/build.gradle +++ b/build.gradle @@ -80,6 +80,8 @@ dependencies { // https://mvnrepository.com/artifact/org.apache.pdfbox/jbig2-imageio implementation group: 'org.apache.pdfbox', name: 'jbig2-imageio', version: '3.0.4' + implementation 'com.github.jai-imageio:jai-imageio-core:1.4.0' + implementation 'com.github.jai-imageio:jai-imageio-jpeg2000:1.3.0' implementation 'commons-io:commons-io:2.13.0' implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0' diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f8cfc519..2e86a2da 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -35,7 +35,7 @@ spring.datasource.url=jdbc:h2:file:./configs/stirling-pdf-DB;DB_CLOSE_DELAY=-1;D spring.datasource.driver-class-name=org.h2.Driver spring.datasource.username=sa spring.datasource.password= -spring.h2.console.enabled=true +spring.h2.console.enabled=false spring.jpa.hibernate.ddl-auto=update # Change the default URL path for OpenAPI JSON diff --git a/src/main/resources/templates/view-pdf.html b/src/main/resources/templates/view-pdf.html index 2cb93dee..e4644d5b 100644 --- a/src/main/resources/templates/view-pdf.html +++ b/src/main/resources/templates/view-pdf.html @@ -27,18 +27,17 @@ See https://github.com/adobe-type-tools/cmap-resources PDF.js viewer - - + + + + - - + + - - + +