如何从pdf(jspdf)删除black bg?

Dee*_*een 5 html css pdf html2canvas jspdf

我已经使用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;
}
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

此代码没有用。这是从html转换为pdf。

还有一个问题。

一些有限的内容仅以pdf格式提供。一些内容不来。

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

如何从PDF中删除黑色背景在此处输入图片说明

Sha*_*ini 0

这是因为您指定的宽度。尝试调整宽度或在 html2canvas 选项中指定。