Pothi Sam

Pothi Sam

  • NA
  • 335
  • 50.4k

Html+css=iTextSharp Pdf

Dec 26 2014 2:44 AM
 public void convertpdf()
         {

             Response.ContentType = "application/pdf";
             Response.AddHeader("content-disposition", "attachment;filename=UserDetails.pdf");
             Response.Cache.SetCacheability(HttpCacheability.NoCache);
             StringWriter sw = new StringWriter();
             HtmlTextWriter hw = new HtmlTextWriter(sw);
             this.Page.RenderControl(hw);
             StringReader sr = new StringReader(sw.ToString());
             Document pdfDoc = new Document(new Rectangle(1050 ,600));
             //Document pdfSTy = new Header(iTextSharp.text.html.Markup.HTML_ATTR_STYLESHEET, "Style.css");
            
             HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
             PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
             pdfDoc.Open();
             htmlparser.Parse(sr);
             pdfDoc.Close();
             Response.Write(pdfDoc);
             Response.End();
}


i convert the page to pdf using iTextSharp but it cant bring Css style inPdf Coversion code are apove Please help