public class PdfNote { public int Create(int id, string path) { try { var file = path; if (System.IO.File.Exists(file)) System.IO.File.Delete(file); Document document = new Document(PageSize.A4, 10, 10, 10, 10); var writer = iTextSharp.text.pdf.PdfWriter.GetInstance(document, new System.IO.FileStream(file, FileMode.Create)); document.Open(); writer.PageEvent = new Footer(); // main content document.Close(); return 1; } catch (Exception ex) { throw ex; } } public partial class Footer : PdfPageEventHelper { public override void OnEndPage(PdfWriter writer, Document doc) { PdfPTable fTbl = new PdfPTable(1); fTbl.TotalWidth = 550; fTbl.DefaultCell.Border = 0; PdfPTable line = new PdfPTable(1); line.DefaultCell.Border = 0; line.DefaultCell.BorderWidthBottom = 0.2f; line.DefaultCell.Padding = 5; line.AddCell(""); fTbl.AddCell(line); PdfPTable footerTbl = new PdfPTable(3); footerTbl.TotalWidth = 550; footerTbl.DefaultCell.Column.Alignment = 1; footerTbl.HorizontalAlignment = Element.ALIGN_CENTER; footerTbl.DefaultCell.Border = 0; footerTbl.AddCell("Print Name:"); footerTbl.AddCell("Signature:"); footerTbl.AddCell("Date:"); PdfPCell cell = new PdfPCell(); cell.Padding = 20; cell.Border = 0; cell.BorderWidthBottom = 1; footerTbl.AddCell(cell); footerTbl.AddCell(cell); footerTbl.AddCell(cell); fTbl.AddCell(footerTbl); fTbl.AddCell(line); fTbl.WriteSelectedRows(0, -1, 15, 110, writer.DirectContent); //footerTbl.WriteSelectedRows(0, -1, 15, 60, writer.DirectContent); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)