简体   繁体   English

将div保存为png-html2canvas-质量模糊

[英]save div as png - html2canvas - blurry quality

Using html2canvas i'm trying to capture a div and save it as a .png file, and it works! 我正在尝试使用html2canvas捕获div并将其另存为.png文件,并且可以正常工作!

(just using window.open in example to simplify it - same quality problem) (仅在示例中使用window.open来简化它-相同的质量问题)

However the image sharpness / quality of the images inside the targeted div is pretty bad. 但是,目标div内的图像清晰度/图像质量非常差。 I'm not quite sure how to improve the image quality/sharpness. 我不太确定如何改善图像质量/清晰度。 Any suggestions ? 有什么建议么 ?

saveAsPNG function: saveAsPNG函数:

saveAsPNG = function(id) {
var target = document.getElementById(id);

  html2canvas(target, {
    onrendered: function(canvas) {
      var data = canvas.toDataURL("image/png", 1);
      window.open(data);     
    }
  });
};

What does html2canvas is not "actually" taking a screenshot but making representation. html2canvas的作用不是“实际”截屏而是显示。 So it builds the screenshot based on the information available on the page. 因此,它将根据页面上可用的信息来构建屏幕截图

Maybe an option not to take blurry images is to use it. 也许不拍摄模糊图像的选择就是使用它。

https://github.com/ivoviz/feedback https://github.com/ivoviz/feedback

This is a jQuery plugin based on html2canvas, which allows you to take screenshots to a certain part of the page. 这是一个基于html2canvas的jQuery插件,可让您将屏幕截图截取到页面的特定部分。 Give it a try :) 试试看 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM