iTextSharp: Header on only First Page

GenXCoders

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.

  1. Also, The table being generated has to have 60 rows on first page and about 65 rows on all other pages (since the header will not be there).

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;
Sea Charp

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Header of Page with iTextSharp

From Dev

Add main header on first page only in TCPDF

From Dev

How to reload the Page by header at first time only

From Dev

Logo image showing only in the first page on page header in Jasper Reports

From Dev

How to include header only for the first page using enscript

From Dev

ITextSharp - include footer on every page but the first and the last

From Dev

I need an SSRS Report with a header on every page, but a logo only on the first page

From Dev

Title on only first page

From Dev

css print mode: display header and footer only on first page of a generated word doc

From Dev

No data, only a table header when rendering first time the 'products#index' page

From Dev

Fixed Header only on one page

From Dev

itextsharp setting trimbox does not work on first page in my document

From Dev

itextsharp setting trimbox does not work on first page in my document

From Dev

ABCpdf only rendering first page

From Dev

JavaScript works only on first page

From Dev

All pages with header excluding first page - RotativaPDF

From Dev

Header and Footer in ITextSharp

From Dev

How to add page header without first page itext 7

From Dev

HTML/CSS: empty page + only header page when printing table

From Dev

iTextSharp insert a page at the beginning

From Dev

iTextSharp vertical page fill

From Dev

Freeze Header in excel using itextSharp

From Dev

Only first page loads javascript in phonegap

From Dev

Crystal Report Shows only first page

From Dev

Primefaces' commandLink works only on the first page of a dataTable

From Dev

flexicapture processor recognize only first page of document

From Dev

How to print only the first page in Crystal Report?

From Dev

ImageButton in Updatepanel fires only on first Page Load

From Dev

Scrapy only scraping first result of each page

Related Related

  1. 1

    Header of Page with iTextSharp

  2. 2

    Add main header on first page only in TCPDF

  3. 3

    How to reload the Page by header at first time only

  4. 4

    Logo image showing only in the first page on page header in Jasper Reports

  5. 5

    How to include header only for the first page using enscript

  6. 6

    ITextSharp - include footer on every page but the first and the last

  7. 7

    I need an SSRS Report with a header on every page, but a logo only on the first page

  8. 8

    Title on only first page

  9. 9

    css print mode: display header and footer only on first page of a generated word doc

  10. 10

    No data, only a table header when rendering first time the 'products#index' page

  11. 11

    Fixed Header only on one page

  12. 12

    itextsharp setting trimbox does not work on first page in my document

  13. 13

    itextsharp setting trimbox does not work on first page in my document

  14. 14

    ABCpdf only rendering first page

  15. 15

    JavaScript works only on first page

  16. 16

    All pages with header excluding first page - RotativaPDF

  17. 17

    Header and Footer in ITextSharp

  18. 18

    How to add page header without first page itext 7

  19. 19

    HTML/CSS: empty page + only header page when printing table

  20. 20

    iTextSharp insert a page at the beginning

  21. 21

    iTextSharp vertical page fill

  22. 22

    Freeze Header in excel using itextSharp

  23. 23

    Only first page loads javascript in phonegap

  24. 24

    Crystal Report Shows only first page

  25. 25

    Primefaces' commandLink works only on the first page of a dataTable

  26. 26

    flexicapture processor recognize only first page of document

  27. 27

    How to print only the first page in Crystal Report?

  28. 28

    ImageButton in Updatepanel fires only on first Page Load

  29. 29

    Scrapy only scraping first result of each page

HotTag

Archive