Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public void pdf()
{
iTextSharp.text.html.simpleparser.StyleSheet styles = new iTextSharp.text.html.simpleparser.StyleSheet();

styles.LoadTagStyle("divM", "border", "2pt solid red");

styles.LoadTagStyle("divM", "size", "60pt");
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Invoice.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);

StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);

divM.RenderControl(htmlTextWriter);
StringReader sr = new StringReader(stringWriter.ToString());
Document doc = new Document(PageSize.A2, 7f, 7f, 7f, 0f);

FontFactory.GetFont("Verdana", 80, iTextSharp.text.BaseColor.RED);

HTMLWorker htmlparser = new HTMLWorker(doc);
htmlparser.SetStyleSheet(styles);
PdfWriter.GetInstance(doc, Response.OutputStream);
doc.Open();
htmlparser.Parse(sr);
doc.Close();
Response.Write(doc);
Response.End();

}

I have tried like this.But my code is not working while applying font size and borders to the pdf using itextsharp.How to modifiy my code please any one help me.
Posted

1 solution

this link may help you
http://www.codeproject.com/Articles/686994/Create-Read-Advance-PDF-Report-using-iTextSharp-in
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900