我使用htmlToPdf创建了一个应用程序,应用程序运行良好。但当我用下面的管道把它部署到我的码头时。
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/*
我添加了这些库,因为它需要它们正确运行。但是它仍然显示了文档中显示的相同的错误。
即:
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
我检查了docker容器的/tmp文件夹,它包含所需的文件作为例外。
发布于 2020-03-03 13:01:10
正如我所看到的,您正在与html2pdf库进行斗争。
但是您忘记了这个库在内部使用wkhtmltopdf。这样你就可以使用那个图书馆了。要在java代码中使用它,可以使用任何包装器。
下面是那个包装器的链接:https://github.com/jhonnymertz/java-wkhtmltopdf-wrapper
例如:
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");
https://stackoverflow.com/questions/60434663
复制相似问题