Firefox上的html2canvas图像问题在chrome上正常工作 [英] html2canvas image issue on firefox While working fine on chrome

查看:521
本文介绍了Firefox上的html2canvas图像问题在chrome上正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用html2canvas.js,它在chrome中可以100%正常工作,而在firefox中,它没有显示div,这是我的目标div中的箭头,只是将图像转换为base64并将其通过ajax发送到服务器,我在其中保存图像并生成pdf.在chrome图像和pdf上,两者均与目标div匹配100%,而当我尝试使用mozilla时,它并没有在图像中渲染一些箭头,这是我的js代码

I am using html2canvas.js and it's working 100% fine in chrome while in firefox it's not showing some div's which are arrows inside my target div am just converting image to base64 and sending it through ajax to server where I save image and generate pdf. On chrome image and pdf both match 100% with target div while when I try with mozilla it's not not rendering some arrows in image here is my js code

 html2canvas(div, {
    canvas: canvas,
    height: useWidth,
    width: useHeight,
    onrendered: function (canvas) {
       m_intSelectedProjectID = parseInt(m_intSelectedProjectID)
        var image = canvas.toDataURL("image/png");
        var l_strBase64 = image.replace('data:image/png;base64,', '');

        var name = 'test'
        $.ajax({
            type: "POST",
            url: "PTServiceRoutines.aspx/AjaxSaveImageFile",
            data: "{'buffer':'" + l_strBase64 + "','p_intSelectedProjectID':'" + m_intSelectedProjectID + "','p_strViewMode':'" + p_strViewMode +"'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: successAjaxSaveImageFile,
            failure: failureAjaxSaveImageFile,
            error: errorAjaxSaveImageFile
        });
        return false;
    }
});

我认为在html上绑定渲染的图像时,不需要显示服务器端原因的代码,即使此处缺少箭头,分别从chrome和firefox上传图像.

I don't think that there is any need to show code from server side cause when I bind rendered image here on html even that has missing arrows here am uploading images from chrome and firefox respectively.

推荐答案

与保存.jpg扩展名相比,我保存的.png扩展名图像在firefox中出现问题,并且解决了我的问题.

I was saving images with .png extension and was getting issue in firefox than I saved them with .jpg extension and it solved my problem.

这篇关于Firefox上的html2canvas图像问题在chrome上正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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