【问题标题】:Low resolution Image jspdf and Html2Canvas低分辨率图像 jspdf 和 Html2Canvas
【发布时间】:2016-01-21 23:08:56
【问题描述】:

我们在 jsPDF 和 HTML2canvas 的帮助下创建 pdf。但是图像分辨率有点高。

有没有办法用 jquery、javascript、jsPDF 和 html2canvas 获取低分辨率图像

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);
    }

【问题讨论】:

    标签: javascript jquery jspdf html2canvas


    【解决方案1】:

    可以使用任何工具降低图像的分辨率,但使用 jquery 降低分辨率可能并不容易。 尝试使用工具减小图像大小并参考。 http://blog.teamtreehouse.com/using-jquery-asynchronously-loading-image

    【讨论】:

      猜你喜欢
      • 2011-04-07
      • 2014-11-20
      • 1970-01-01
      • 2017-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多