Shah
Shah

Reputation: 1654

Error when exporting data to PDF from C#

I am writing a PDF file from C# like this:

Response.ContentType = "application/vnd.pdf";
Response.AddHeader("content-disposition", "attachment;filename=test.pdf");
Response.Write("<table border='1px'>");

/* Print Headers */
Response.Write("<tr>");
Response.Write("<th colspan='" + colspan + "'style='background-color:SlateGray;font-size:16;height:25;color:white;'><b>List of Candidates  "</b></th>");
Response.Write("</tr>");
Response.Write("<tr>");

When I save the file and open it, it throws an exception that file is not supported file type .. or file has been damaged.

Upvotes: 2

Views: 1384

Answers (1)

Shoaib Shaikh
Shoaib Shaikh

Reputation: 4585

to create pdf form html you should have a look at it.

Render PDF in iTextSharp from HTML with CSS

to create tables using itextsharp have a look at it

http://www.mikesdotnetting.com/Article/86/iTextSharp-Introducing-Tables

Upvotes: 1

Related Questions