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

  • Home
  • SEARCH
  • 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 8979411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:50:30+00:00 2026-06-15T19:50:30+00:00

I have done the export to PDF from gridview using iTextSharp. Since the gridview

  • 0

I have done the export to PDF from gridview using iTextSharp. Since the gridview columns are more the columns in PDF is not aligned and it is so small. I tried writing styles in both codebehind and .aspx page. But the size is not changing.

.aspx Page

 <asp:GridView ID="grdResult" runat="server" AutoGenerateColumns="true" Width="100%"
      CellPadding="3" CellSpacing="3" Font-Size="10pt">
      <HeaderStyle Font-Bold="true" Width="250px" />
 </asp:GridView>

.cs Page

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=MARGEmployees.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
HtmlForm frm = new HtmlForm();
grdResult.Parent.Controls.Add(frm);
frm.Attributes["runat"] = "server";
frm.Controls.Add(grdResult);
frm.RenderControl(hw);
grdResult.HeaderRow.Style.Add("width", "15%");
grdResult.HeaderRow.Style.Add("font-size", "10px");
grdResult.Style.Add("font-family", "Tahoma");
grdResult.Style.Add("font-size", "8px");
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 7f, 7f, 7f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();

Please help me on this

  • 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-15T19:50:32+00:00Added an answer on June 15, 2026 at 7:50 pm

    Try to change your pdf doc size in code behind.

    // Try any one of these

    Document pdfDoc = new Document(PageSize.A3, 7f, 7f, 7f, 0f);
    Document pdfDoc = new Document(PageSize.A2, 7f, 7f, 7f, 0f);
    Document pdfDoc = new Document(PageSize.A1, 7f, 7f, 7f, 0f);
    

    Since the size of the pdf doc is set the columns are compressed.
    If you change the size it wil work.

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

Sidebar

Related Questions

I want to export my grpah/text data in pdf format using QT code.I have
I am not an expert in Git, but I have seen this done before
What I have done is I have taken the class-files from my eclipse project
I am using Rational software Architect(RSA) which is like eclipse .Now i have done
I have done quite a bit of research on this issue and have not
I have done already a lot of small (and also bigger reports) with report
I have a gridview control in ASP.Net 2.0 and i need to export this
I have done a script in PHP to export a MySQL table into a
I have done the obvious -- the USB driver was installed from the latest
Have done quite a bit of searching for a guide (of any substance) for

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.