Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Displaying Total PageNr in Header

$
0
0
Hello,

I want to display the total page number in my header.

I expected
page 1 of 2 on the first page
page 2 of 2
on the second page

What I get is:
page 1 of 1 on the first page
page 2 of 2 on the second page

Code sample (C#):
FileStream fs = new FileStream(output, FileMode.Create);
Pdf pdf = new Pdf(fs);
Aspose.Pdf.Generator.Section section = new Aspose.Pdf.Generator.Section();
pdf.Sections.Add(section);
Aspose.Pdf.Generator.HeaderFooter hf = new Aspose.Pdf.Generator.HeaderFooter(section);
section.OddFooter = section.EvenFooter = hf;
hf.Paragraphs.Add(new Aspose.Pdf.Generator.Text(hf, "page $p of $P"));  //  $p $Sp $SP $SN $D

Aspose.Pdf.Generator.Table table = new Aspose.Pdf.Generator.Table();

for (int iRow = 0; iRow < 100; iRow++)
{
  Aspose.Pdf.Generator.Row row = table.Rows.Add();

  for (int iCol = 0; iCol < 5; iCol++)
  {
    Aspose.Pdf.Generator.Cell cell = row.Cells.Add();
    Text cellText = new Text("Text");
    cell.Paragraphs.Add(cellText);
  }
}

section.AddParagraph(table);
pdf.Close();


What am I doing wrong?
Regards

Viewing all articles
Browse latest Browse all 3131

Trending Articles