gpt4 book ai didi

html - 如何从 pdf(jspdf) 中去除黑色背景?

转载 作者:太空狗 更新时间:2023-10-29 16:45:37 27 4
gpt4 key购买 nike

我已经使用 html2canvas 和 jspdf 从 html 转换为 pdf。

我使用的是 a3 格式的 pdf,但内容宽度为 ix 1000px。所以在 1000px 之后,pdf 显示黑色背景。

canvas{
background: #fff !important;
background-color: #fff !important
margin: 0;
}
#cisForm {
padding: 10px;
width: 1000px;
margin: 0;
background: #fff !important;
}

cisForm 是正文

<script type="text/javascript">
window.onload = function() {
html2canvas(document.body).then(function(canvas) {
background:'#fff',
document.getElementById("cisForm").appendChild(canvas);
document.body.appendChild(canvas);
var context = canvas.getContext("2d");
context.fillStyle="#FFFFFF";

l = {
orientation: 'p',
unit: 'pt',
format: 'a3',
compress: true,
fontSize: 8,
lineHeight: 1,
autoSize: false,
printHeaders: true
};

var doc = new jsPDF(l, "", "");
doc.addImage(canvas.toDataURL("image/jpeg"),"jpeg",0,0)
window.location=doc.output("datauristring")
});
}
</script>

此代码没有用处。这是从 html 到 pdf 的转换。

还有一个问题。

一些有限的内容只有 pdf 格式。一些内容没有出现。

我们需要在任何地方设置页数吗?

如何从 pdf 中删除黑色背景 enter image description here

最佳答案

尝试将 body 背景颜色设置为#FFFFFF。

关于html - 如何从 pdf(jspdf) 中去除黑色背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32472441/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com