【发布时间】:2017-12-25 17:22:31
【问题描述】:
我正在使用 css、jquery 和 nodejs(带有 ejs 和 express)来创建一个网站,我需要导出一个带有一些文本的 div 和一些带有背景图像的 div 作为图像(jpg 或 png),但是最好是pdf。我尝试使用 html2canvas 但后来我读到它与 nodejs 不兼容。 我也尝试使用 jspdf,但它不会导出 pdf 文件中的 css。 所以我想知道是否有人知道可以用nodejs做到这一点的解决方案。
这是我的 ejs 代码示例:
<%for(var j = 0; j < rawData.scanner.length; ++j) {%>
<div class="grid" id="grid-<%= data.scanner[j].camera%>"
style="
width : <%= parseFloat(data.widthScreen) + 17%>px;
height : <%= parseFloat(data.heightScreen) + 17%>px;
position : absolute;
left : 0px;
top : 60px;
overflow-x : scroll;
overflow-y : scroll;
display : none;">
<%for(var i = 0; i < data.scanner[j].parts; ++i) {%>
<div class="fenetre" id=<%= data.scanner[j].name + "-img" + i%>
style="
background-image : url(<%= (data.scanner[j].imagePath)%>);
width : <%= data.scanner[j].width%>px;
height : <%= data.scanner[j].height%>px;
position:absolute;
top: 0px;
left: <%= (i * data.scanner[j].left)%>px;"
>
</div>
<%}%>
</div>
<%}%>
【问题讨论】:
标签: html css node.js html2canvas