JsPDF多页数据正在裁剪

问题描述

下面用于创建PDF的代码,我的要求是制作PDF内容 不要选择我已经实现的(应该像一个图像)。现在我的问题是 PDF将在第二页中生成更多内容,但底部标题部分没有填充。

我尝试了各种选择,例如autotablehtmlToJson,但很多选择都没有成功。

I need to add padding at bottom of first page and header of second page

                   html2canvas($('#mydiv')[0]).then(canvas => {
                        try {
                             contentH = $('#mydiv').height();
                             var img = canvas.toDataURL("image/png",1.0);
                             $w = $actw = canvas.width;
                             $h = $acth = canvas.height;
                             var pdf = new jsPDF("p","mm","Letter");
                             var width = $maxw = pdf.internal.pageSize.width;
                             var height = $maxh = pdf.internal.pageSize.height;
                             if (!$maxw) $maxw = width;
                             if (!$maxh) $maxh = height;
                             if ($w > $maxw) {
                              $w = $maxw;
                              $h = Math.round($acth / $actw * $maxw);
                              }
                              pdf.addImage(img,'JPEG',$w,$h);
                              $count = Math.ceil($h / $maxh) - 1;
                              $count = Math.ceil($h / $maxh) - 1;
                              for (var i = 1; i <= $count; i++) {
                              position = - $maxh * i
                              //pdf.text(10,20,'Hello World');
                              pdf.addPage(img,$h);
                              pdf.addImage(img,position,$h);
                              }
                             pdf.save("file.pdf");
                              } catch (e) {
                              alert("Error description: " + e.message);
                              }
                             });

我需要在第一页的底部和第二页的页眉(也可以有多个页面)的顶部添加填充,我已将图像附加为参考。

希望有人可以帮助我,提前感谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)