public void pdf()
{
iTextSharp.text.html.simpleparser.StyleSheet styles = new iTextSharp.text.html.simpleparser.StyleSheet();
PdfPTable table = new PdfPTable(3);
table.TotalWidth = 400f;
Document document = new Document(PageSize.A2, 88f, 88f, 10f, 10f);
MemoryStream memoryStream = new MemoryStream();
PdfWriter writer = PdfWriter.GetInstance(document, memoryStream);
document.Open();
PdfContentByte content = writer.DirectContent;
iTextSharp.text.Rectangle rectangle = new iTextSharp.text.Rectangle(document.PageSize);
rectangle.Left += document.LeftMargin;
rectangle.Right -= document.RightMargin;
rectangle.Top -= document.TopMargin;
rectangle.Bottom += document.BottomMargin;
content.SetColorStroke(iTextSharp.text.BaseColor.BLUE);
content.Rectangle(rectangle.Left, rectangle.Bottom, rectangle.Width, rectangle.Height);
content.Stroke();
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());
HTMLWorker htmlparser = new HTMLWorker(document);
htmlparser.SetStyleSheet(styles);
PdfWriter.GetInstance(document, Response.OutputStream);
document.Open();
htmlparser.Parse(sr);
document.Close();
Response.Write(document);
Response.End();
}
Here i am not getting any borders in pdf page..and i tried another way.
styles.LoadStyle("pdf", "border", "1");
If i applied this line,i got every line with border
styles.LoadStyle("pdf", "border-top", "1");
styles.LoadStyle("pdf", "border-bottom", "1");
styles.LoadStyle("pdf", "border-left", "1");
styles.LoadStyle("pdf", "border-right", "1");
styles.LoadStyle("pdf", "size", "4");
If i applied this code ,then i am not getting any border .. How can i add page borders in pdf page using Itextsharp.dll file