我的Android应用程序呈现包含画布上的WebView。云打印想要一个PDF。我如何才能生成PDF和我的WebView发送到云打印?
My Android app renders a WebView containing a canvas. Cloud Print wants a PDF. How can I generate a PDF with my WebView to send to Cloud Print?
推荐答案
您可以先捕获帆布为PNG:(从stackoverflow答案)
You could first capture the canvas as a png: (taken from stackoverflow answer)
var canvas = document.getElementById("mycanvas");
var img = canvas.toDataURL("image/png");
然后下一步进入一个PDF此。我还没有看到基于JavaScript的转换器,但人们可以发送PNG到自定义Web服务(可能是在谷歌企业应用套件,亚马逊AWS或传统的托管的机器上运行),它简单的返回一个PDF文件。 ImageMagick的可以在这里使用一个包装CGI脚本或者您可以使用一些库。或者有可能做内的Android应用程序的转换。
Then next step get this into a pdf. I haven't seen a javascript based converter, but one could send the png to a custom web service (perhaps running on Google Apps, Amazon AWS or a traditional hosted machine) which simple returns a pdf. ImageMagick could be used here with a wrapper cgi script or you could use some library. Alternatively it might be possible to do the conversion within the android app.
相关推荐
最新文章