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
It seems that some Replaceabel Symbols including $P are not useable in Direct-to-file mode.
Hi,
Yes you are correct. When using Direct-to-File mode, the replaceable symbol $P does not work. For further details, please take a look over Writing PDF directly. We are sorry for your inconvenience.