Java Docker抛出异常-Html2Pdf库
我使用创建了一个应用程序,该应用程序运行良好。但当我用下面的管道将它部署到我的docker时Java Docker抛出异常-Html2Pdf库,java,wkhtmltopdf,html-to-pdf,Java,Wkhtmltopdf,Html To Pdf,我使用创建了一个应用程序,该应用程序运行良好。但当我用下面的管道将它部署到我的docker时 FROM openjdk:8-slim RUN apt-get update && apt-get install -y --no-install-recommends \ libc6 \ libx11-6 \ libxext6 \ libxrender1 \ libstdc++6 \ libssl1.0 \
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文件夹,它包含所需的文件作为例外,因为我可以看到您正在努力使用html2pdf库 但是您忘记了这个库在内部使用。所以你可以使用这个库。要在java代码中使用它,可以使用任何包装器 以下是指向该包装器的链接: 例如:
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");
Pdf=newpdf();
pdf.addPageFromString(“Müller”);
pdf.addPageFromUrl(“http://www.google.com");
//添加目录
pdf.addToc();
//`wkhtmltopdf`shell命令接受不同类型的选项,如全局、页面、页眉和页脚以及toc。请参阅'wkhtmltopdf-H'了解完整的解释。
//所有选项都作为数组传递,例如:
addParam(新参数(“--无页脚行”)、新参数(“--页眉html”、”file:///header.html"));
addParam(新参数(“--enableJavaScript”);
//为目录添加样式
addTocParam(新参数(“--xsl样式表”,“my_toc.xsl”);
//保存PDF
pdf.saveAs(“output.pdf”);
如果您能为现有库提供解决方案,那就更好了。