Click here to Skip to main content
12,507,845 members (56,015 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
Hello all,
I am generating a pdf using following code
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 11-Apr-11 19:25pm
Updated 11-Apr-11 21:00pm
m@dhu29.7K
v3

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Use ITextSharp

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

Exporting GridView to PDF Document[^]
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160927.1 | Last Updated 12 Apr 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100