I created an application using htmlToPdf and the application worked fine. but when I deployed it to my docker with the below pipeline.
FROM openjdk:8-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
libc6 \
libx11-6 \
libxext6 \
libxrender1 \
libstdc++6 \
libssl1.0 \
libfreetype6 \
fontconfig \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
I added these libraries because it needs them to run correctly. But still it's showing the same error showed in the documentation.
which is:
Caused by: java.lang.UnsatisfiedLinkError: Unable to load library '/tmp/io.woo.htmltopdf/wkhtmltox/0.12.5/libwkhtmltox.so': Native library (tmp/io.woo.htmltopdf/wkhtmltox/0.12.5/libwkhtmltox.so) not found in resource path
I checked the /tmp folder of docker container it contains the required file as the exceptions
As I can see you are struggling with html2pdf library.
But you are forgetting that this library usage wkhtmltopdf internally. so you can use that library. To use it in your java code you can use any wrapper.
Here is the link to that wrapper: https://github.com/jhonnymertz/java-wkhtmltopdf-wrapper
for example:
Pdf pdf = new Pdf();
pdf.addPageFromString("<html><head><meta charset=\"utf-8\"></head><h1>Müller</h1></html>");
pdf.addPageFromUrl("http://www.google.com");
// Add a Table of Contents
pdf.addToc();
// The `wkhtmltopdf` shell command accepts different types of options such as global, page, headers and footers, and toc. Please see `wkhtmltopdf -H` for a full explanation.
// All options are passed as array, for example:
pdf.addParam(new Param("--no-footer-line"), new Param("--header-html", "file:///header.html"));
pdf.addParam(new Param("--enable-javascript"));
// Add styling for Table of Contents
pdf.addTocParam(new Param("--xsl-style-sheet", "my_toc.xsl"));
// Save the PDF
pdf.saveAs("output.pdf");