【问题标题】:html2pdf not rendering a pdf image in front of another imagehtml2pdf 不在另一个图像前面呈现 pdf 图像
【发布时间】:2021-06-22 23:04:23
【问题描述】:

我正在尝试将 html 页面转换为 pdf,我在上传的 jpg 中动态添加的画布元素前面有一个透明 png,当我运行脚本时,它会呈现 pdf,但只呈现 jpg 图像。我已经尝试了无数次迭代,还尝试了不同的渲染库,如 html2canvas 等

.proof_images {
max-width:960px;
height:679px;
z-index:1;
}

.proof {
position:relative;
margin:0;
padding:0;
width:100%;
height:100%;
z-index:2;
}

<div id="print_proof" class="print_proof">
<div class="proof">
<img id="image_proof_background" class="proof_images" src="https://www.eimedia.com.au/wp-content/uploads/explainer.jpg" style="margin-bottom:20px; opacity:1;">
</div>
</div>

$("#generate").click(function() {

var element = document.getElementById('print_proof');
var opt = {
    margin:       1,
    filename:     'myfile.pdf',
    image:        { type: 'jpeg', quality: 0.98 },
    html2canvas:  { scale: 2 },
    jsPDF:        { unit: 'in', format: 'A4', orientation: 'portrait' }
};

html2pdf().set(opt).from(element).save();

});

【问题讨论】:

    标签: html jquery css pdf html2pdf


    【解决方案1】:

    我认为你可以使用 wkhtmltopdf 命令行工具

    请看这个https://wkhtmltopdf.org/

    【讨论】:

      猜你喜欢
      • 2019-01-18
      • 1970-01-01
      • 1970-01-01
      • 2020-01-05
      • 2022-10-20
      • 2022-11-08
      • 2019-12-03
      • 2021-02-05
      • 2013-06-29
      相关资源
      最近更新 更多