I'm trying to make pdf from div using c#. To complete this object i m using iTextShap. I found solution on Internet to create pdf from given html code.
<asp:Panel ID="Panel1" runat="server">
<table style="border:1px solid">
<tr style="background-color:green;">
<td style="width:10%; color:white; font-weight:bold">Sr.</td>
<td style="width:60%; color:white; font-weight:bold">Particular</td>
<td style="width:25%; color:white; font-weight:bold">Price</td>
</tr>
<tr style="background-color:#ffffff">
<td style="width:10%">01.</td>
<td style="width:60%">3 keywords and printers</td>
<td style="width:25%">2000 INR</td>
</tr>
<tr style="background-color:#e1c5ed">
<td style="width:10%">02.</td>
<td style="width:60%">3 acer laptops</td>
<td style="width:25%">90000 INR</td>
</tr>
<tr style="background-color:#ffffff">
<td style="width:10%">03.</td>
<td style="width:60%">2 dell laptops</td>
<td style="width:25%">60000 INR</td>
</tr>
</table>
</asp:Panel>
my browser's output look like this html output image
my button click event's code given below
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=pdffile.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
Panel1.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
Above code created pdf without any css style. I want to ask how to apply css and create pdf as like as webpage? When i create pdf my table look like this PDF output Can anybody help me. Thanks in advance.