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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:42:03+00:00 2026-05-23T20:42:03+00:00

I am generating one PDF from the Code Behind File using StringWriter and HtmlTextWriter.

  • 0

I am generating one PDF from the Code Behind File using StringWriter and HtmlTextWriter.
The Coding is given below:

System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView gv = new GridView();
gv.BorderStyle = BorderStyle.None; 
gv.DataSource = dt2;
gv.DataBind();
gv.RenderControl(hw);
string str = sw.ToString();
string str1 = "<table width='100%' border='1'><tr><td><img src='" + Server.MapPath("App_Themes/Ribo/ribologo.bmp") + "' alt='' width=75px height=75px /></td><td align='center' colspan='8' font size='3'><h2><b>MATERIAL RECEIPT CUM INSPECTION REPORT(MRIR)</b></h2</td></tr>";
str1 += "<tr><td font size='3'>MRIR NO</td><td font size='3'>Date</td><td align='center' font size='3'>JOB DESCRIPTION</td><td font size='3'>SUPPLIER NAME</td><td font size='3'>DC NO</td><td font size='3'>DATE</td><td font size='3'>LWB NO/DATE</td><td font size='3'>INVOICE NO</td><td font size='3'>DATE</td></tr>";
str1 += "<tr><td font size='3'>" + txtMRVNumber.Text + "</td><td font size='3'></td><td font size='3'></td><td font size='3'>" + TDSSVendor.Text + "</td><td font size='3'>" + txtDCNumber.Text + "</td><td font size='3'></td><td font size='3'>" + txtLWBNo.Text + "</td><td font size='3'>" + txtInvoiceNo.Text + "</td><td font size='3'></td></tr>";
str1 += "<tr><td rowspan='2' font size='3'>DESCRIPTION</td><td font size='3' colspan='2' align='center'>SIZE(mm)</td><td colspan='6'></td></tr>";
str1 += "<tr><td font size='3' colspan='2'>" + sw + "</td><td colspan='6'></td></tr></table>";           

if (str.StartsWith("<div>"))
{
    str = str1;
}
System.IO.StringReader sr = new System.IO.StringReader(str);
iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(iTextSharp.text.PageSize.A3.Rotate(), 40f, 10f, 40f, 2f);
iTextSharp.text.html.simpleparser.HTMLWorker htmlparser = new iTextSharp.text.html.simpleparser.HTMLWorker(pdfDoc);
iTextSharp.text.pdf.PdfWriter.GetInstance(pdfDoc, Response.OutputStream);

Here, I generated my desired PDF. But the table is displaying at the top of the PDF. So I want to display at the centre of the PDF as well as I want to increase the height of the Table. How to do this?

I tried like the below:

 string str1 = "<table **height='100%'** width='100%' border='1'><tr>.....

But it displays as the same. How to increase the height of the table? I need all your suggestions please.

  • 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-23T20:42:03+00:00Added an answer on May 23, 2026 at 8:42 pm

    That alone is not going to do it. You can wrap the generated .pdf in another table (1 row, 1 column), and place that table in the sole TD of the new table, then just vertical align (valign=’middle’) the enclosing TD.

    This is the only way I know how to do what you are asking, although I do not know if it will work for you:

         <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
                <title>Untitled Page</title>
    
    <!-- Put this on your presentation page -->
                <style type="text/css">
                    html, body {
                        margin: 0;
                        padding: 0;
                        height: 100%;
                        border: none;
                    }
                </style>
            </head>
            <body>
                <table style="height: 100%" width="100%" align="center">
                    <tr>
                        <td valign="middle" align="center">
    
    
                            <table>
                                <tr>
                                    <td valign="middle">
                                    <!-- Embed your .pdf here -->
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </body>
            </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with generating .pdf's from PHP using this library: http://www.fpdf.org/ I am currently
I'm currently generating SQL insert statements from more than one tables, and in the
We are generating pdf using apache's xsl fo engine, namely fop 0.95. We have
I have a program that is manually generating a PDF using PDFsharp in C#.
I have written code to generate thumbnails from pdf files & save them as
I'm developing an electronic invoicing system, and one of our features is generating PDFs
I have the requirement of generating UML Diagrams for one of my C++ assignments.
I have the requirement of generating UML Diagrams for one of my C++ assignments.
While generating charts using RS 2008 betas, RC0 and such., I never specified any
I'm generating ICalendar (.ics) files. Using the UID and SEQUENCE fields I can update

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.