css - firefox 上的 html2canvas 图像问题 在 chrome 上工作正常

标签 css png html2canvas

我正在使用 html2canvas.js,它在 chrome 中 100% 正常工作,而在 firefox 中它没有显示一些 div,它们是我目标 div 中的箭头,我只是将图像转换为 base64,然后通过 ajax 将其发送到我保存图像和生成pdf。在 chrome 图像和 pdf 上都与目标 div 100% 匹配,而当我尝试使用 mozilla 时,它不会在图像中呈现一些箭头,这是我的 js 代码

 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 上绑定(bind)渲染图像时,即使缺少箭头,我也分别从 chrome 和 firefox 上传图像。 Image from chrome

this one is from firefox

最佳答案

我用 .png 扩展名保存图像,在 firefox 中遇到问题,而不是用 .jpg 扩展名保存图像,它解决了我的问题。

关于css - firefox 上的 html2canvas 图像问题 在 chrome 上工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50323795/

相关文章:

javascript - 有没有办法用Javascript修改图像?

javascript - 如何在javascript中将带有路线的谷歌地图转换为图像

javascript - 生成 html 图表并另存为图像

html - 如何让预加载器隐藏滚动条?

javascript - CSS 样式不适用于第二个下拉菜单

html - Flexbox:水平和垂直居中

iphone - iOS PNG 图像旋转 90 度

jquery - 使用两个选择表单框但只出现一个

Delphi,处理 png 和位图的 ImageList

windows - 使用 Phantom JS 将文件夹中的所有 HTML 文件转换为 PNG