简体   繁体   English

如何在服务器端C#中使用Javascript生成的图像?

[英]How to use the image generated by Javascript at server side C#?

I am following this tutorial. 我正在关注本教程。 http://www.battlehorse.net/page/topics/charts/save_google_charts_as_image.html http://www.battlehorse.net/page/topics/charts/save_google_charts_as_image.html

This is the demo page. 这是演示页面。 http://www.battlehorse.net/attach/topics/charts/google_charts_to_image.html http://www.battlehorse.net/attach/topics/charts/google_charts_to_image.html

When we click on Convert to Image button, javascript convert the canvas to image. 当我们单击“转换为图像”按钮时,JavaScript将画布转换为图像。 I want to use that pie chart to generate a PDF report which happens at server side. 我想使用该饼图生成在服务器端发生的PDF报告。

Could you please advise the best solution for this? 您能为此建议最好的解决方案吗? Thanks. 谢谢。

您已经从画布上获取了图像,因此其余部分与此处相同: C#中的JPG至PDF转换器

I found another way to do this. 我找到了另一种方法。

I created SaveImage.aspx which accept form post data(Base64String(data:image/png;base64), and file name) and save the file. 我创建了SaveImage.aspx,它接受表单发布数据(Base64String(data:image / png; base64)和文件名)并保存文件。

On button click, I generate the google chart and send ajax post data(data:image/png;base64) to SaveImage.aspx and that page save the image. 在单击按钮时,我生成Google图表并将ajax发布数据(data:image / png; base64)发送到SaveImage.aspx,然后该页面保存图像。 And then generate the PDF using that image. 然后使用该图像生成PDF。

Feel free to point out if you guys have a better solution. 请随意指出,如果你们有更好的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM