I am using iTextSharp for a project in ASP.NET. I have generated what I want so far.
The Issue 1. I want the HEADER to be displayed ONLY on First Page of my PDF. But, the Header content appears on every new page generated.
Code so Far:
PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream);
Phrase phrase = null;
PdfPCell cell = null;
Color color = null;
pdfDoc.Open();
int columns = grdGridPrint.Columns.Count;
// Table and PdfTable classes removed in version 5.XXX
PdfPTable table = new PdfPTable(columns);
// table.TotalWidth = 500f;
// Draw first-page-only header
//ColumnText ct = new ColumnText(writer.DirectContent);
//XMLWorkerHelper.GetInstance().ParseXHtml(new ColumnTextElementHandler(ct), new StringReader(html));
//ct.SetSimpleColumn(document.Left, document.Top, document.Right, document.GetTop(-PDFMarginTop), 0, Element.ALIGN_MIDDLE);
//ct.Go();
phrase = new Phrase();
phrase.Add(new Chunk("Elam Fataka\u00AE \n", FontFactory.GetFont("Arial", 15, Font.BOLD, Color.BLACK)));
phrase.Add(new Chunk("Mahakali Complex, Tarsa Road,Kanhan \n", FontFactory.GetFont("Arial", 10, Font.NORMAL, Color.BLACK)));
phrase.Add(new Chunk("Proprietor : Liladhar Barve, ", FontFactory.GetFont("Arial", 10, Font.BOLD, Color.BLACK)));
phrase.Add(new Chunk("(M) 9326560090 | (O) 07102-236297 \n", FontFactory.GetFont("Arial", 8, Font.NORMAL, Color.BLACK)));
phrase.Add(new Chunk("\n\n", FontFactory.GetFont("Arial", 7, Font.NORMAL, Color.BLACK)));
phrase.Add(new Chunk("All Agent List - Total Agent :" + grdGridPrint.Rows.Count.ToString() + "\n", FontFactory.GetFont("Arial", 15, Font.NORMAL, Color.BLACK)));
phrase.Add(new Chunk("Printing Date : " + DateTime.Today.ToString("dd/MM/yyyy") + "\n", FontFactory.GetFont("Arial", 10, Font.NORMAL, Color.BLACK)));
phrase.Add(new Chunk("\n\n", FontFactory.GetFont("Arial", 7, Font.NORMAL, Color.BLACK)));
cell = ClsPDF.PhraseCell(phrase, PdfPCell.ALIGN_CENTER);
cell.VerticalAlignment = PdfCell.CHUNK;
Just create a paragraph on the first page.
pdfDoc.Add(new Paragraph("This Is My Header"));
Your rows will automatically spill over to the next page as needed.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments