Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1037761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:53:24+00:00 2026-05-16T14:53:24+00:00

Please note this link Render HTML as an Image is not helpful. In previously

  • 0

Please note this link Render HTML as an Image is not helpful.

In previously asked question answered said they don’t get what I want to do exactly so here’s is the full code also.

I simply want that instead of a TABLES I rendered an image (of the content) on the page.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.IO;
using System.Text;
using System.Data;
using System.Drawing;


public partial class _Default : System.Web.UI.Page 
{
protected void Page_Load(object sender, EventArgs e)
{

    System.Web.UI.WebControls.Panel panelmain = new System.Web.UI.WebControls.Panel();
    System.Web.UI.WebControls.Literal abc = new System.Web.UI.WebControls.Literal();
    abc.Text = "as<br/>dasdas<br/>dasdad";


    DataSet ds = new DataSet();
    DataTable dt;
    DataRow dr;
    DataColumn idCoulumn;
    DataColumn nameCoulumn;

    dt = new DataTable();
    idCoulumn = new DataColumn("ID", Type.GetType("System.Int32"));
    nameCoulumn = new DataColumn("Name", Type.GetType("System.String"));
    dt.Columns.Add(idCoulumn);
    dt.Columns.Add(nameCoulumn);
    dr = dt.NewRow();
    dr["ID"] = 1;
    dr["Name"] = "Name1";
    dt.Rows.Add(dr);

    dr = dt.NewRow();
    dr["ID"] = 2;
    dr["Name"] = "Name2";
    dt.Rows.Add(dr);

    ds.Tables.Add(dt);

    System.Web.UI.WebControls.GridView grid1 = new 
    System.Web.UI.WebControls.GridView();
    grid1.DataSource = ds;
    grid1.DataBind();

    panelmain.Controls.Add(abc);
    panelmain.Controls.Add(grid1);

    string toexport;
    toexport = RenderControl(panelmain);

    Byte[] bitmapData = new Byte[100000];
    bitmapData = Convert.FromBase64String(FixBase64ForImage(toexport));
    System.IO.MemoryStream streamBitmap = new System.IO.MemoryStream(bitmapData);
    Bitmap bitImage = new Bitmap((Bitmap)Image.FromStream(streamBitmap));

    Response.ContentType = "image/gif";
    Response.AppendHeader("Content-Disposition", "inline;filename=tm.gif");
    Response.BufferOutput = true;
    Response.Charset = "utf-8";
    Response.Write(bitImage);
    Response.End();

    }



public string FixBase64ForImage(string Image)
{
    System.Text.StringBuilder sbText = new System.Text.StringBuilder(Image, Image.Length);

    sbText.Replace("\r\n", String.Empty);

    sbText.Replace(" ", String.Empty);

    return sbText.ToString();
}



public string RenderControl(Control ctrl)
{
    StringBuilder sb = new StringBuilder();
    StringWriter tw = new StringWriter(sb);
    HtmlTextWriter hw = new HtmlTextWriter(tw);

    ctrl.RenderControl(hw);
    Response.Write(sb);

    return sb.ToString();



}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:53:24+00:00Added an answer on May 16, 2026 at 2:53 pm

    In your previous question you already received an answer (by me), referring to another SO thread where this question was answered. The second answer in that thread links to another page on the web where the whole process of starting a WebBrowser object, rending a page, capturing the image, converting that to your preferred image file format, saving it locally is explained. Not a straightforward task (expect to spend some hours), but not too hard either.

    To repeat the answer in the referred to question, just have a look at this WinCustomize.com article, download the source and experiment

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please note: This is a question about the Eclipse plugin Subversive , and not
Please note this is not a question about online/hosted SVN services. I am working
[Please note that this is a different question from the already answered How to
Please note this question related to performance only. Lets skip design guidelines, philosophy, compatibility,
Please note that this is not homework and i did search before starting this
Please note that this question is from 2008 and now is of only historic
Please note this application will never be running on a server system. I am
Please note that I did ask this on Super User and received absolutely no
Can I write XSD schema for this? Please note that the category is repeated
For the 2nd <h3>World!</h3> in this sample scenario ( Please note <..> elements are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.