HTML2canvas生成模糊图像 [英] HTML2canvas generates Blurry images

查看:2472
本文介绍了HTML2canvas生成模糊图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jsPDF,它使用html2canvas从一些html元素生成图像并插入.pdf文件。但是在html2canvas有一个问题,它从html生成模糊的图像。请参阅以下示例:

I am using jsPDF and it uses html2canvas to generate an image from some html element and insert on the .pdf file. But there is a problem on html2canvas, it generates blurry images from the html. See example below:

HTML内容:

http://puu.sh/7SZz4.png

html2canvas生成的图片:

html2canvas generated image:

http://puu.sh/7SZAT.png

有任何方法来修复它,或有什么更好的选择获取图像形式html?

Is there any way to fix it or is there any better option to get the image form html?

谢谢!

推荐答案

我发现了我的问题。发生我的屏幕是一个Retina显示,所以当canvas2html将渲染HTML,由于视网膜屏幕上的像素密度的差异,图像被模糊。

I have found out my problem. Happens that my screen is a Retina Display, so when the canvas2html will render the HTML, due to the difference of pixel density on retina screen, the image is rendered blurred.

在此找到解决方案:

https://github.com/cburgmer/rasterizeHTML.js/blob/master/examples/retina.html

这篇关于HTML2canvas生成模糊图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆