Angular Html2canvas for table仅在可见行中剪切图像(无滚动)
我正在尝试下载pdf格式的表格,这是页面的底部组件,但在截图时,它只打印不滚动的可见行 我没有对整个页面使用html2canvas,只对页面底部的表格使用,甚至下载按钮也在页面底部,整个表格可见:Angular Html2canvas for table仅在可见行中剪切图像(无滚动),angular,pdf-generation,html2canvas,Angular,Pdf Generation,Html2canvas,我正在尝试下载pdf格式的表格,这是页面的底部组件,但在截图时,它只打印不滚动的可见行 我没有对整个页面使用html2canvas,只对页面底部的表格使用,甚至下载按钮也在页面底部,整个表格可见: download() { var data = document.getElementById('table'); //Id of the table html2canvas(data).then(canvas => { var imgData = canv
download()
{
var data = document.getElementById('table'); //Id of the table
html2canvas(data).then(canvas => {
var imgData = canvas.toDataURL('image/png,1.0')
var pdf = new jsPdf('l', 'mm', 'a4'); // A4 size page of PDF
var width = pdf.internal.pageSize.getWidth();
var height = pdf.internal.pageSize.getHeight();
let widthRatio = width / canvas.width;
let heightRatio = height / canvas.height;
let ratio = widthRatio > heightRatio ? heightRatio : widthRatio
pdf.addImage(imgData, "PNG", 0, 0, canvas.width * ratio, canvas.height * ratio,);
pdf.save('MYPdf.pdf'); // Generated PDF
});
}