San*_*mas 6 jquery html2canvas
嗨,我正在使用 HTML2canvas 插件在模态对话框中转换 DIV。转换工作正常。但是那个 div 有垂直滚动。所以在最终图像上,滚动隐藏区域后没有任何转换。只有 div 的可见顶部在渲染图像中。那么如何将整个 div(与滚动无关)转换为图像..这是我的代码
$('#modal_sidebyside .modal-content').html2canvas({
onrendered: function (canvas) {
//Set hidden field's value to image data (base-64 string)
$('.export-sidebyside').hide();
//$('#modal_sidebyside .modal-body').css({ 'overflow-y': 'auto', 'height': 'auto' });
//$('#modal_sidebyside .modal-content').css({ 'overflow-y': 'auto', 'height': 'auto' });
var img = canvas.toDataURL('image/jpeg');
var link = document.getElementById("download-sidebyside");
link.download = "SidebySide.jpg"; //Setup name file
$(link).html("Download");
link.href = img.replace(/^data[:]image\/(png|jpg|jpeg)[;]/i, "data:application/octet-stream;");
$('.export-sidebyside').show();
// $('#modal_sidebyside .modal-body').css({ 'overflow-y': 'auto', 'height': '80%' });
// $('#modal_sidebyside .modal-content').css({ 'overflow-y': 'auto', 'height': '100%' });
//document.body.appendChild(link);
}
});
Run Code Online (Sandbox Code Playgroud)