Click here to Skip to main content
Rate this: bad
good
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
Edited 11-Apr-11 21:00pm
m@dhu29.4K
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.
 
^]
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,745
1 OriginalGriff 6,696
2 CPallini 5,315
3 George Jonsson 3,599
4 Gihan Liyanage 2,650


Advertise | Privacy | Mobile
Web01 | 2.8.140922.1 | Last Updated 12 Apr 2011
Copyright © CodeProject, 1999-2014
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