Javascript 低分辨率图像jspdf和Html2Canvas
我们正在jsPDF和HTML2canvas的帮助下创建pdf。但是图像分辨率有点高 有没有办法通过jquery、javascript、jsPDF和html2canvas获得低分辨率图像Javascript 低分辨率图像jspdf和Html2Canvas,javascript,jquery,jspdf,html2canvas,Javascript,Jquery,Jspdf,Html2canvas,我们正在jsPDF和HTML2canvas的帮助下创建pdf。但是图像分辨率有点高 有没有办法通过jquery、javascript、jsPDF和html2canvas获得低分辨率图像 function addElement(element, doc, opt, newPage, callback) { var thiscreen = element; //Get the original background color. var origina
function addElement(element, doc, opt, newPage, callback) {
var thiscreen = element;
//Get the original background color.
var originalBGColor = thiscreen.style.backgroundColor;
//Change the background color of the element to desired color.
if (opt.bgColor)
thiscreen.style.backgroundColor = opt.bgColor;
var options = options || {};
options.elements = [thiscreen];
//Increment the in-progress counter.
counter++;
console.log('adding' + counter);
console.log(element);
//The complete callback method.
options.complete = setTimeout(function(images) {
//Decrement the in-progress counter since the image is successfully generated..
counter--;
console.log('complete' + counter);
console.log(element);
var queue = html2canvas.Parse(thiscreen, images, options),
canvas = html2canvas.Renderer(queue, options);
//Reset the background color.
thiscreen.style.backgroundColor = originalBGColor;
//Add the generated image to PDF document.
doc.addImage(canvas.toDataURL(), 'png', opt.x, opt.y, opt.width, opt.height);
//Call the callback method if any
if (callback) {
callback();
}
}, 500);
//Conver the html to PNG using html2canvas util.
html2canvas.Preload(thiscreen, options);
}
可以使用任何工具降低图像的分辨率,但使用jquery降低分辨率可能并不容易。 尝试使用工具缩小图像大小并参考。