Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,
I am generating a pdf using following code
C#
HtmlForm form_html = new HtmlForm();
       form_html.Controls.Add(GridView1);
       string attachment = "attachment; filename=Article.pdf";
       Response.ClearContent();
       Response.AddHeader("content-disposition", attachment);
       Response.ContentType = "application/pdf";
       StringWriter stw = new StringWriter();
       HtmlTextWriter htextw = new HtmlTextWriter(stw);
       divtext.RenderControl(htextw);
       GridView1.RenderControl(htextw);
       Document document = new Document(PageSize.A4, 3f, 4f, 1f, 0f);
       PdfWriter.GetInstance(document, Response.OutputStream);
       document.Open();
       StringReader str = new StringReader(stw.ToString());
       HTMLWorker htmlworker = new HTMLWorker(document);
       htmlworker.Parse(str);
       document.Close();
       Response.Write(document);
       Response.End();



code works fine but it is not showing border and background color of
and grid view.

can someone please tell me how to show these.

thanks
Posted
Updated 11-Apr-11 21:00pm
v3

1 solution

Use ITextSharp

The below article explains how to/ how not to export to PDF.

Exporting GridView to PDF Document[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900