base64转换到正常PNG拷贝/粘贴 [英] Convert Base64 to normal PNG for copy/pasting

查看:149
本文介绍了base64转换到正常PNG拷贝/粘贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的使用过程缺憾的HTML电子邮件模板如下:

I've got an HTML email template that's using a kludgy process as follows:


  1. 从MySQL提取数据,并把它变成一个HighCharts图

  2. 转换的HighCharts SVG使用canvg以帆布

  3. 渲染使用canvas.toDataURL画布为Base64 PNG

所有的很好,图像显示了罚款(除了在Internet Explorer中的某些诡异),但这里的难题是:

All's well and good, the image shows up fine (except for some quirkiness in Internet Explorer), but here's the rub:

我希望用户能够将整个网页复制并粘贴到Outlook,并发送出去的电子邮件。但是,Outlook(和其他一些客户我试过)将不通过复制粘贴收到Base64编码的PNG文件 - 有一个空格所在的形象应该是

I'd like users to be able to copy and paste the entire web page into Outlook and send it out as an email. However, Outlook (and a few other clients I've tried) won't receive Base64 PNGs via copy paste -- there's a blank space where the image should be.

有谁知道的方式向Base64编码转换成普通PNG使得它能够生存下来的复制/粘贴?也许这需要保存PNG服务器?

Does anyone know of a way to convert the Base64 into a normal PNG such that it can survive the copy/paste? Maybe this requires saving the PNG to server?

任何帮助将大大AP preciated。

Any help would be greatly appreciated.

谢谢了。

推荐答案

我一直在想这个,因为你的最后一个问题,我想出来的3个选项:

I've been thinking about this since your last question and I've come up with 3 options:


  1. 棒与你有什么。

  2. 从toDataURL乘坐的base64字符串,提交回通过AJAX服务器,在后端将其转换为PNG,其存储在服务器和服务PNG返回页面。

两个


  1. 渲染highcharts在用户的浏览器SVG。

  2. 提交SVG字符串通过AJAX调用后台服务器。

  3. 在后端后,生成一个POST请求(像这里描述请参见使用PHP的POST请求)到highcharts在的 http://export.highcharts.com/ 。从看highcharts 请求必须包含以下贴出变量:

  1. Render highcharts SVG on the users browser.
  2. Submit that SVG string to your backend server via AJAX call.
  3. On the backend, generate a post request (something like described here see Using PHP for POST Request) to the highcharts exporting server at http://export.highcharts.com/. From looking at the highcharts source the request needs to contain the following posted variables:

文件名:PNG文件名搜索
   输入:从plotOptions,类型,线,棒材等。结果
   宽度:在所需的PNG结果的像素宽度
   SVG:SVG的字符串

filename: png filename
type: from the plotOptions, the type, line, bar,etc..
width: the width in pixels of the desired png
svg: the svg string

获取所产生的PNG,将其保存到你的服务器,服务于它正常。

  • Get the resulting PNG, save it to your server, serve it normally.

    切换到使用的Java API Highcharts 。你必须让你的服务器上运行此。一旦你做到了,不过,你完全可以在后台生成图表和刚刚担任了PNG文件。

    Switch to using the Java Highcharts API. You'd have to get this running on your server. Once you did, though, you could generate your charts entirely on the backend and just serve up the PNG file.

    这篇关于base64转换到正常PNG拷贝/粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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