HTML渲染为图像

编程入门 行业动态 更新时间:2024-10-28 11:21:54
本文介绍了HTML渲染为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我产生的优惠券基于动态输入和裁剪图像,我使用NTML和CSS现在显示优惠券,问题是,印刷这已成为因打印时的背景是如何消失的问题和其他的问题,所以我认为最好的解决办法是能够基于HTML生成图像,或设立某种形式的模板,它接受字符串和图像,并生成使用反馈作为一个背景图像的图像并把顶部的优惠券信息。

I'm generating a coupon based on dynamic input and a cropped image, and I'm displaying the coupon using ntml and css right now, the problem is, printing this has become an issue because of how backgrounds disappear when printing and other problems, so I think the best solution would be to be able to generate an image based on the html, or set up some kind of template that takes in strings and an image, and generates an image using the image fed in as a background and puts the coupon information on top.

有什么,已经做了这个?

Is there anything that does this already?

这是一个ASP.NET 3.5的C#网站!

This is for an ASP.NET 3.5 C# website!

先谢谢了。

编辑:这将会是巨大的,如果输出有可能成为基于HTML的输入,如优惠券是通过操作使用jQuery的DOM和拖拽的东西设计的,这一切工作正常,它只是当它涉及到印刷(纸)有Z-索引问题。

edit: It'd be great if the output could be based on the HTML input, as the coupon is designed by manipulating the DOM using jQuery and dragging stuff around, it all works fine, it's just when it comes to the printing (to paper) it has z-indexing issues.

推荐答案

你可以做的是创造改变响应类型是你想要的格式,然后将图像插入流中aspx页面。我创建了一个酒吧code发电机,做类似的事情。不包括生成图像的所有手续,你的Page_Load会是这个样子:

What you can do is create an aspx page that changes the response type to be in the format you want and then put the image into the stream. I created a barcode generator that does a similar thing. Excluding all the formalities of generating the image, you'll Page_Load will look something like this:

Bitmap FinalBitmap = new Bitmap(); MemoryStream msStream = new MemoryStream(); strInputParameter == Request.Params("MagicParm").ToString() // Magic code goes here to generate your bitmap image. FinalBitmap.Save(msStream, ImageFormat.Png); Response.Clear(); Response.ContentType = "image/png"; msStream.WriteTo(Response.OutputStream); if ((FinalBitmap != null)) FinalBitmap.Dispose();

这就是它!然后你有你的形象做的是设置的URL是类似RenderImage.aspx?MagicParm =呜呼或任何你需要的。这样,你可以把它渲染任何你想做的指定。

and that's it! Then all you have to do in your image is set the URL to be something like RenderImage.aspx?MagicParm=WooHoo or whatever you need. That way you can have it render whatever you want to specify.

更多推荐

HTML渲染为图像

本文发布于:2023-10-30 01:26:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541359.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!