Create image of Html code with c#
<p>I have created html code and then save this html page as an image . The <code>html</code> controls which I have created is showing properly in the image  with all images and background color. It is woking fine on localhost.</p>

<p>but I am trying to creating html code to image on the server. the image is creating but it's not showing anything like bgcolor, images, etc.</p>

<p>only blank image is showing.</p>

<p>Code :</p>

<p>Using Ajax calling function from client side I am sending the html content to the serverside</p>

<p>Server Side Method</p>

<pre><code>[System.Web.Services.WebMethod()]
       public static void GenerateTemplateImage(string html_Content, string TemplateName)
        {
            var t = new Thread(MakeScreenshot);
            t.SetApartmentState(ApartmentState.STA);
            t.Start();
        }


        public static void MakeScreenshot()
        {
            Bitmap bitmap;
            string html = string.Empty;

            string Title = string.Empty;
            string Meta = string.Empty;
            string Style = string.Empty;
            string ScriptBefore = string.Empty;
            string ScriptAfter = string.Empty;
            string Scripthead = string.Empty;

            html="&lt;div&gt;&lt;div id='s_p_box-1' style='background-color: rgb(24, 0, 238); width: 109px; height: 75px;&gt;Welcome &lt;/div&gt;' &lt;br/&gt; &lt;img id='template1' class='template' style='border:1px solid green; height:142px;width:116px' src='http://ace.demos.classicinformatics.com/Advertiser-Admin/Campaign/UserTemplate/template1.jpg'&gt;&lt;/div&gt;";

            WebBrowser wb = new WebBrowser();



            wb.Navigate("about:blank");

            if (wb.Document != null)
            {
                wb.Document.Write(html);
            }

            wb.DocumentText = html;

            wb.ScrollBarsEnabled = false;
            wb.ScriptErrorsSuppressed = true;

            // Set the size of the WebBrowser control
            // Take Screenshot of the web pages full width
          //  wb.Width = wb.Document.Body.ScrollRectangle.Width;
            wb.Width = 1024;
            // Take Screenshot of the web pages full height
          //  wb.Height = wb.Document.Body.ScrollRectangle.Height;
            //wb.Height = 786;
            wb.ScrollBarsEnabled = true;

            if (wb.Height &lt;= 0)
            {
                wb.Height = 1024;
            }
            //if (wb.Width &lt;= 400)
            //{
            //    wb.Width = 700;
            //}

            // Get a Bitmap representation of the webpage as it's rendered in the WebBrowser control
            //Bitmap bitmap = new Bitmap(wb.Width, wb.Height);

            //using (bitmap = new Bitmap(wb.Width, wb.Height))
            using (bitmap = new Bitmap(wb.Width, wb.Height))
            {

                //wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height));
                wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height));
                //string imgPath = HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["ImgPath"].ToString());
                //string imgPath="C:\\Projects\\aec\\Ace-A-Metric\\Advertiser-Admin\\Campaign\\UserTemplate\\";
                string imgPath = URlPath + "test123" + ".bmp";
                //bitmap.Save(@"D:\" + txtTempName.Text + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
                bitmap.Save(imgPath, System.Drawing.Imaging.ImageFormat.Bmp);
                //string imgpath = Path.Combine(HttpContext.Current.Server.MapPath("~") + "Advertiser-Admin\\Campaign\\UserTemplate\\" + txtTempName.Text +".bmp");
                //bitmap.Save(imgpath, System.Drawing.Imaging.ImageFormat.Bmp);
            }
            wb.Dispose();
            GC.Collect();
        }
</code></pre>
