[英]Missing image in pdf generated by html-pdf
I am using HTML-pdf library to convert HTML page into pdf.我正在使用 HTML-pdf 库将 HTML 页面转换为 pdf。 I am getting the dynamic part on the pdf however the image is reportedly missing.
我在 pdf 上获得了动态部分,但据报道该图像丢失了。 I have tried to use all methods at my disposable, however, the image isn't appearing in the generated pdf.
我尝试使用一次性的所有方法,但是,图像没有出现在生成的 pdf 中。 What should I do?
我应该怎么办? Below is my HTML template:
下面是我的 HTML 模板:
<head>
<title>Certificate</title>
<!-- <link rel="stylesheet" href="../stuff/certificate.css"> -->
<style>
html,
body {
height: 100%;
width: 100%;
}
img{
height: 100%;
width: 100%;
margin:0px;
}
#name{
margin-top:-420px;
margin-left: 60px;
}
p{
font-size:40px;
color:black;
font-weight:400;
text-align: center;
}
</style>
</head>
<body>
<img src="../stuff/certificate.jpg">
<div id="name"><p><%=name%></p></div>
</body>
</html>
I am getting the name as per my wish, however the image isn't appearing at all.我按照我的意愿得到了这个名字,但是图像根本没有出现。 Kindly help.
请帮忙。 The image is in different folder as compared to the html one.
与 html 相比,该图像位于不同的文件夹中。
Try to use a JS library that detect when images have been loaded.尝试使用检测图像何时加载的 JS 库。
You can use it like this:你可以像这样使用它:
<script src="https://npmcdn.com/imagesloaded@4.1/imagesloaded.pkgd.min.js"></script>
<script type="text/javascript">
imagesLoaded(document.body, function() {
window.print();
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.