首页 新闻 赞助 找找看

asp.net 将某div内文字生成图片保存,显示的是一行 怎样才能有格式呢?

0
悬赏园豆:20 [待解决问题]

传入的content   要保存到图片的内容是div  加table的内容   但是生成图片后只是一行,<br/>也是不识别的

生成content的部分代码如下:

    emailContent += "<div>" + "Dear: " + "&nbsp;&nbsp;&nbsp;" + toUser + "</div>";
                    emailContent += xcty + "<br/>";
                    emailContent += "<table><tr><td>" + "products_model:" + dr["products_model"].ToString() + "</td></tr>";
                    emailContent += "<tr><td>" + "旅途信息:" + dr["tourInfo"].ToString() + "</td></tr>";
                    emailContent += "</table>";

如题,代码如下:

protected bool  CreatImage(string content,string  orderId)
        {
            Bitmap img = null;
            bool res = false;
            if (content != "")
            {
                img = new Bitmap((int)Math.Ceiling((content.Length * 18.0)), 30);
                Graphics g = Graphics.FromImage(img);
                try
                {
                    g.Clear(Color.White);
                    Font font = new Font("Arial", 15.5f, (FontStyle.Bold));
                    System.Drawing.Drawing2D.LinearGradientBrush brush =
                        new LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Color.Black, Color.DarkRed,
                            1.2f, true);
                    g.DrawString(content, font, brush, 2, 2);
                    g.DrawRectangle(new Pen(Color.Silver), 0, 0, img.Width - 1, img.Height - 1);
                    string path = Server.MapPath("~../../emailImages/");
                    img.Save(path + orderId + ".jpg");
                    res = true;
                }
                catch (Exception ex)
                {
                    res = false;
                }
                finally
                {
                    g.Dispose();
                    img.Dispose();
                }
            }

            return res;

        }

请教各位该怎么弄呢,让content的内容得到展示  而不是只显示一行

lijunmomo的主页 lijunmomo | 初学一级 | 园豆:34
提问于:2014-12-01 09:18
< >
分享
所有回答(1)
0

你又没有可能是其他的呢,比如说你自己布局的时候给这个Content留下的布局就这么少呢,或者说还其他的寄到了,你把这个图片的样子单独输出一下看看,就像做验证码那样

_Vegetables | 园豆:586 (小虾三级) | 2014-12-01 13:55
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册