Last post Mar 29, 2011 11:02 AM by msdevm
Mar 26, 2011 01:32 PM|msdevm|LINK
Can any one explain how to convert HTML to System.Drawing.Image?
For instance I have an HTML that display an photo
<table border=0 width"100%" background="photo/myphoto.jpg">
I would like to create an images from the table background jpg and content in td
Mar 27, 2011 07:53 PM|Small Peter|LINK
First let me make sure I understand your question. You want to create an image from your table background and draw text in your table onto the created image, right?
If so, you need to use classes under System.Drawing
Documentation for System.Drawing from MSDN can be found at
And here I write this sample you may find helpful
string photoPath = Server.MapPath("~/photo/myphoto.jpg");
System.Drawing.Image img = System.Drawing.Image.FromFile(photoPath);
Graphics graph = Graphics.FromImage(img);
Font font = new Font("Verdana", 12, FontStyle.Regular);
graph.DrawString("Picture name", font, Brushes.Black, 0, 0);
graph.DrawString("Author name", font, Brushes.Black, 0, 20);
graph.DrawString("Date Created name", font, Brushes.Black, 0, 40);
string savePath = Server.MapPath("~/photo/output.jpg");
Note that you need to play with the font, brush and positions. The image will be created from "~/photo/myphoto.jpg" and will be saved to "~/photo/output.jpg" with the text on it.
Mar 29, 2011 11:02 AM|msdevm|LINK
That was great? Thanks for reply also I appriciate the coding tips.
Can the same be converted to adobe PDF using the System.Drawing as well?