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 8691985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:13:52+00:00 2026-06-13T00:13:52+00:00

I am using one static table which is in a panel conrol how to

  • 0

I am using one static table which is in a panel conrol
how to convert html content inside the panel to pdf
please help me to convert to pdf as soon as button export is clicked

Aspx code:-

<table width="100%">  
   <tr>
      <td>
          <asp:Panel ID="pnlPerson" runat="server">
            <table border="1" style="font-family: Arial; font-size: 10pt; width: 200px">
                <tr>
                    <td colspan="2" style="background-color: #18B5F0; height: 18px; color: White; border: 1px solid white">
                        <b>Personal Details</b>
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Name:</b>
                    </td>
                    <td>
                        <asp:Label ID="lblName" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Age:</b>
                    </td>
                    <td>
                        <asp:Label ID="lblAge" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>City:</b>
                    </td>
                    <td>
                        <asp:Label ID="lblCity" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Country:</b>
                    </td>
                    <td>
                        <asp:Label ID="lblCountry" runat="server"></asp:Label>
                    </td>
                </tr>
            </table>
          </asp:Panel>
        <asp:Button ID="btnExport" runat="server" Text="Export"  />
      </td>
  </tr>
</table>

C#.net Code:-

if (!IsPostBack)
{
    //Populate DataTable
    DataTable dt = new DataTable();
    dt.Columns.Add("Name");
    dt.Columns.Add("Age");
    dt.Columns.Add("City");
    dt.Columns.Add("Country");
    dt.Rows.Add();
    dt.Rows[0]["Name"] = "Mudassar Khan";
    dt.Rows[0]["Age"] = "27";
    dt.Rows[0]["City"] = "Mumbai";
    dt.Rows[0]["Country"] = "India";

    //Bind Datatable to Labels
    lblName.Text = dt.Rows[0]["Name"].ToString();
    lblAge.Text = dt.Rows[0]["Age"].ToString();
    lblCity.Text = dt.Rows[0]["City"].ToString();
    lblCountry.Text = dt.Rows[0]["Country"].ToString();
}

protected void btnExport_Click(object sender, EventArgs e)
{
}

Please do send me the C# Code for this Export button

  • 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-06-13T00:13:53+00:00Added an answer on June 13, 2026 at 12:13 am

    Thats what I did and it is creating the pdf as required

    protected void btnExport_Click(object sender, EventArgs e)
        {
            var document = new Document(PageSize.A4, 50, 50, 25, 25);
            var output = new FileStream(@"C:\Temp\PersonDetail.pdf", FileMode.Create);
            var writer = PdfWriter.GetInstance(document, output);
            document.Open();
    
    
            StringBuilder sb = new StringBuilder();
            StringWriter tw = new StringWriter(sb);
            HtmlTextWriter hw = new HtmlTextWriter(tw);
            pnlPerson.RenderControl(hw);
            var html = sb.ToString();
            var parsedHtmlElements = HTMLWorker.ParseToList(new StringReader(html), null);
    
            // Enumerate the elements, adding each one to the Document...
            foreach (var htmlElement in parsedHtmlElements)
                document.Add(htmlElement as IElement);
    
            document.Close();
    
        }
    

    Please read this nice article by Scott Mitchell at https://web.archive.org/web/20211020001758/https://www.4guysfromrolla.com/articles/030911-1.aspx and decide what is best for you. As suggested by the author in this article, parsing the HTML and adding it into the PDF has limited support and may not work for complex HTML structures.

    Let me know if it helps.

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

Sidebar

Related Questions

I have a static Html Table which contains one button Add and when clicking
I am using Twitter Bootstrap on two project, one is a static HTML website
I have a table that has its content filled using one of the two
I saw one book on C++ mentioning that navigating inheritance hierarchies using static cast
I am using a Miglayout to create a table-like layout for one of my
I have a large static list which is basically a lookup table, so I
I am creating a Table using a CustomTableModel which extends AbstractTableModel. I am not
I have a table view in one of my viewcontrollers which gets set to
I have a problem by using the ORMlite framework with more than one table
We have multiple tables that contain static key/value pairs, which are currently pulled using

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.