Aspose .Net Paging (Page $p of $P ) not working

Hi, the (Page $p of $P) not working on my .net version. It just display the text as it is Page $p of $P.
Below is the code snippet, please have a look and let me know.

using Aspose.Pdf;
using Aspose.Pdf.Text;
using Sasfin.Notifications.Contract.Entities;

namespace Sasfin.Notifications.Host.Templates
{
public class MonthlyAccountsStatement
{
public MonthlyAccountsStatement() { }

    public object GenerateMonthlyAccountPdf(string accountNumber, Contract.Requests.NotificationRequest request)
    {
        // The path to the documents directory.
        //string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

        Document doc = new Document();
        // Specify the left margin info for the PDF file
        doc.PageInfo.Margin.Left = 25;
        // Specify the Right margin info for the PDF file
        doc.PageInfo.Margin.Right = 25;
        doc.PageInfo.Margin.Top = 280;
        Page page = doc.Pages.Add();

        // Header table begin

        Aspose.Pdf.Table headerTable = new Table
        {
            ColumnWidths = "50 230 80 95 95"
        };

        TextState tableStyle = new TextState
        {
            Font = FontRepository.FindFont("Arial"),
            FontSize = 8,
            FontStyle = FontStyles.Regular
        };

        TextState rightText = new TextState
        {
            HorizontalAlignment = HorizontalAlignment.Right
        };

        TextState numberingText = new TextState
        {
            HorizontalAlignment = HorizontalAlignment.Right,
        };

        TextState tinfo = new TextState
        {
            Font = FontRepository.FindFont("Arial"),
            FontSize = 8,
            FontStyle = FontStyles.Regular
        };

        TextState footerText = new TextState
        {
            Font = FontRepository.FindFont("Arial"),
            FontSize = 7,
            FontStyle = FontStyles.Regular
        };

        TextState headerInfo = new TextState
        {
            Font = FontRepository.FindFont("Arial"),
            FontSize = 8,
            FontStyle = FontStyles.Bold
        };

        TextState headerText = new TextState
        {
            FontSize = 8,
            FontStyle = FontStyles.Bold,
            ForegroundColor = Color.FromArgb(255, 255, 255)
        };

        TextState centerText = new TextState
        {
            HorizontalAlignment = HorizontalAlignment.Center
        };

        Aspose.Pdf.MarginInfo headerCellPadding = new Aspose.Pdf.MarginInfo
        {
            Top = 0,
            Bottom = 4,
            Left = 0,
            Right = 2
        };

        Aspose.Pdf.MarginInfo numberingCellPadding = new Aspose.Pdf.MarginInfo
        {
            Top = 0,
            Bottom = 2,
            Left = 0,
            Right = 0
        };

        Aspose.Pdf.MarginInfo headerCellPadding2 = new Aspose.Pdf.MarginInfo
        {
            Top = 5,
            Bottom = 5,
        };

        // create margin object

        Aspose.Pdf.Table pdfTable = new Table
        {
            ColumnWidths = "50 230 80 95 95"
        };


        pdfTable.DefaultCellTextState = tinfo;
        pdfTable.RepeatingRowsCount = 3;


        Aspose.Pdf.Row row = pdfTable.Rows.Add();
        Aspose.Pdf.Cell cell;
        //cell = row.Cells.Add("Page $p of $P");
        cell = row.Cells.Add("Page $p of $P");
        cell.ColSpan = 5;
        cell.DefaultCellTextState = numberingText;
        cell.DefaultCellTextState.FontStyle = FontStyles.Bold;

        Aspose.Pdf.Row row1 = pdfTable.Rows.Add();
        cell = row1.Cells.Add("Transactions");
        cell.ColSpan = 5;
        cell.BackgroundColor = Color.FromArgb(69, 102, 158);
        cell.DefaultCellTextState.ForegroundColor = Color.FromArgb(255, 255, 255);
        cell.DefaultCellTextState.FontSize = 11;
        cell.DefaultCellTextState.FontStyle = FontStyles.Bold;

        Aspose.Pdf.Row row2 = pdfTable.Rows.Add();
        row2.BackgroundColor = Color.FromArgb(155, 157, 164);
        row2.DefaultCellTextState = headerText;
        cell = row2.Cells.Add("Date");
        cell = row2.Cells.Add("Transaction Description");
        cell = row2.Cells.Add("Interest Rate (%)");
        cell.DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Center;
        cell = row2.Cells.Add("Transaction(R)");
        cell.DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Right;
        cell = row2.Cells.Add("Balance(R)");
        cell.DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Right;


        Aspose.Pdf.Row rowInhalt;


        List<Transactions> transactions = new List<Transactions>();
        foreach(Transactions tnx in  request.Statement.Transactions)
        {
            transactions.Add(tnx);
        }

        List<UnclearedEffects> unclearedTransactions = new List<UnclearedEffects>();
        foreach (UnclearedEffects uncl in request.Statement.UnclearedEffects)
        {
            unclearedTransactions.Add(uncl);
        }

        for (int i = 0; i <= transactions.Count; i++)
        {
            rowInhalt = pdfTable.Rows.Add();
            if (i % 2 == 0)
            {
                // Row styling(color) fuction
                rowInhalt.BackgroundColor = Color.FromArgb(232, 233, 234);
            }
            else
            {
                rowInhalt.BackgroundColor = Color.FromArgb(255, 255, 255);
            }
            rowInhalt.Cells.Add(transactions[i].EffectiveDate.ToString());//"20200701"
            rowInhalt.Cells.Add(transactions[i].Descripition);//"TAP-TO-PAY POS PURCHASE VISA LOCAL [01] PNP FAM NEWMARKET ALBERTON ZA"
            rowInhalt.Cells.Add(transactions[i].Fee.ToString()).DefaultCellTextState = centerText;
            rowInhalt.Cells.Add(transactions[i].Debit.ToString()).DefaultCellTextState = rightText;
            rowInhalt.Cells.Add(transactions[i].Credit.ToString()).DefaultCellTextState = rightText;
        }
        for (int i = 0; i <= unclearedTransactions.Count; i++)
        {
            rowInhalt = pdfTable.Rows.Add();
            if (i % 2 == 0)
            {
                // Row styling(color) fuction
                rowInhalt.BackgroundColor = Color.FromArgb(232, 233, 234);
            }
            else
            {
                rowInhalt.BackgroundColor = Color.FromArgb(255, 255, 255);
            }
            rowInhalt.Cells.Add(unclearedTransactions[i].EffectiveDate.ToString());//"20200701"
            rowInhalt.Cells.Add(unclearedTransactions[i].Descripition);//"TAP-TO-PAY POS PURCHASE VISA LOCAL [01] PNP FAM NEWMARKET ALBERTON ZA"
            rowInhalt.Cells.Add(unclearedTransactions[i].Fee.ToString()).DefaultCellTextState = centerText;
            rowInhalt.Cells.Add(unclearedTransactions[i].Debit.ToString()).DefaultCellTextState = rightText;
            rowInhalt.Cells.Add(unclearedTransactions[i].Credit.ToString()).DefaultCellTextState = rightText;
        }

        //////////////
        ///
        Aspose.Pdf.Table spacerPdfTable = new Table
        {
            ColumnWidths = "180 100 80 95 95"
        };


        // Set the default cell padding to the MarginInfo object
        spacerPdfTable.DefaultCellTextState = tinfo;

        Aspose.Pdf.Row spacerRow = spacerPdfTable.Rows.Add();
        Aspose.Pdf.Cell spacerCell;
        spacerCell = spacerRow.Cells.Add("");
        spacerRow.IsInNewPage = true;
        spacerCell.ColSpan = 5;
        spacerCell.BackgroundColor = Color.FromArgb(255, 255, 255);
        spacerCell.DefaultCellTextState.ForegroundColor = Color.FromArgb(255, 255, 255);
        spacerCell.DefaultCellTextState.FontSize = 11;
        spacerCell.DefaultCellTextState.FontStyle = FontStyles.Bold;


        ///
        //////////////
        ///
        Aspose.Pdf.Table spacerPdfTableNB = new Table
        {
            ColumnWidths = "180 100 80 95 95"
        };


        // Set the default cell padding to the MarginInfo object
        spacerPdfTableNB.DefaultCellTextState = tinfo;

        Aspose.Pdf.Row spacerRowNB = spacerPdfTableNB.Rows.Add();
        Aspose.Pdf.Cell spacerCellNB;
        spacerCellNB = spacerRowNB.Cells.Add("");
        spacerCellNB.ColSpan = 5;
        spacerCellNB.BackgroundColor = Color.FromArgb(255, 255, 255);
        spacerCellNB.DefaultCellTextState.ForegroundColor = Color.FromArgb(255, 255, 255);
        spacerCellNB.DefaultCellTextState.FontSize = 11;
        spacerCellNB.DefaultCellTextState.FontStyle = FontStyles.Bold;


        ///
        ///
        Aspose.Pdf.Table interestPdfTable = new Table
        {
            ColumnWidths = "130 150 80 95 95"
        };

        interestPdfTable.DefaultCellTextState = tinfo;
        interestPdfTable.RepeatingRowsCount = 3;

        Aspose.Pdf.Row interestRow = interestPdfTable.Rows.Add();
        Aspose.Pdf.Cell interestCell;
        //interestCell = interestRow.Cells.Add("Page $p of $P");
        interestCell = interestRow.Cells.Add("Page $p of $P");
        interestCell.ColSpan = 5;
        interestCell.DefaultCellTextState = rightText;
        interestCell.DefaultCellTextState.FontStyle = FontStyles.Bold;

        Aspose.Pdf.Row interestRow1 = interestPdfTable.Rows.Add();
        interestCell = interestRow1.Cells.Add("Interest Schedule");
        interestCell.ColSpan = 5;
        interestCell.BackgroundColor = Color.FromArgb(69, 102, 158);
        interestCell.DefaultCellTextState.ForegroundColor = Color.FromArgb(255, 255, 255);
        interestCell.DefaultCellTextState.FontSize = 11;
        interestCell.DefaultCellTextState.FontStyle = FontStyles.Bold;

        Aspose.Pdf.Row interestRow2 = interestPdfTable.Rows.Add();
        interestRow2.BackgroundColor = Color.FromArgb(155, 157, 164);
        interestRow2.DefaultCellTextState = headerText;
        interestCell = interestRow2.Cells.Add("Period");
        interestCell = interestRow2.Cells.Add("Interest Rate (%)");
        interestCell.DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Center;
        interestCell = interestRow2.Cells.Add("Days");
        interestCell.DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Center;
        interestCell = interestRow2.Cells.Add("Interest Amount (R)");
        interestCell.DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Right;
        interestCell = interestRow2.Cells.Add("Interest Balance (R)");
        interestCell.DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Right;


        Aspose.Pdf.Row interestRowInhalt;

        for (int i = 1; i <= 8; i++)
        {
            interestRowInhalt = interestPdfTable.Rows.Add();
            if (i % 2 == 0)
            {
                // Row styling(color) fuction
                interestRowInhalt.BackgroundColor = Color.FromArgb(232, 233, 234);
            }
            else
            {
                interestRowInhalt.BackgroundColor = Color.FromArgb(255, 255, 255);
            }
            interestRowInhalt.Cells.Add("20200701 - 20200702");
            interestRowInhalt.Cells.Add("0.25").DefaultCellTextState = centerText;
            interestRowInhalt.Cells.Add("8").DefaultCellTextState = centerText;
            interestRowInhalt.Cells.Add("0.01").DefaultCellTextState = rightText;
            interestRowInhalt.Cells.Add("0.51").DefaultCellTextState = rightText;
        }
        ////////////
        ///
        Aspose.Pdf.Table closingPdfTable = new Table
        {
            ColumnWidths = "180 100 80 95 95"
        };


        // Set the default cell padding to the MarginInfo object
        closingPdfTable.DefaultCellTextState = tinfo;
        closingPdfTable.RepeatingRowsCount = 2;

        Aspose.Pdf.Row closingRow = closingPdfTable.Rows.Add();
        Aspose.Pdf.Cell closingCell;
        closingCell = closingRow.Cells.Add("Closing Balance as at " + request.DateTime);// "20200731"
        closingCell.ColSpan = 5;
        closingCell.BackgroundColor = Color.FromArgb(69, 102, 158);
        closingCell.DefaultCellTextState.ForegroundColor = Color.FromArgb(255, 255, 255);
        closingCell.DefaultCellTextState.FontSize = 11;
        closingCell.DefaultCellTextState.FontStyle = FontStyles.Bold;

        Aspose.Pdf.Row closingRow2 = closingPdfTable.Rows.Add();
        closingRow2.BackgroundColor = Color.FromArgb(155, 157, 164);
        closingRow2.DefaultCellTextState = headerText;
        closingCell = closingRow2.Cells.Add("Interest Balance (R)");
        closingCell = closingRow2.Cells.Add("Capital Balance (R)");
        closingCell.DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Center;
        closingCell.ColSpan = 2;
        closingCell = closingRow2.Cells.Add("Total Balance (R)");
        closingCell.DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Right;
        closingCell.ColSpan = 2;

        Aspose.Pdf.Row closingRow3 = closingPdfTable.Rows.Add();
        closingCell = closingRow3.Cells.Add("0.51");
        closingCell = closingRow3.Cells.Add("0.51");
        closingCell.DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Center;
        closingCell.ColSpan = 2;
        closingCell = closingRow3.Cells.Add("0.51");
        closingCell.DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Right;
        closingCell.ColSpan = 2;

        //Header code begin

        Aspose.Pdf.Image img = new Aspose.Pdf.Image();
        img.File = "https://beyond-online.sasfin.com/Sasfin.DocumentConversion.Host/Content/images/sasfin-logo.jpg";
        // Set the image width to 60
        img.FixWidth = 90;
        img.FixHeight = 34;

        //////////////
        ///
        Aspose.Pdf.Table headerTitleTable = new Table
        {
            ColumnWidths = "180 100 80 95 95"
        };


        // Set the default cell padding to the MarginInfo object
        headerTitleTable.DefaultCellTextState = tinfo;

        Aspose.Pdf.Row headerTitleRow = headerTitleTable.Rows.Add();
        Aspose.Pdf.Cell headerTitleCell;
        headerTitleCell = headerTitleRow.Cells.Add("");
        headerTitleCell.ColSpan = 4;
        headerTitleCell = headerTitleRow.Cells.Add("");
        headerTitleCell.Paragraphs.Add(img);

        Aspose.Pdf.Row headerTitleRow1 = headerTitleTable.Rows.Add();
        headerTitleCell = headerTitleRow1.Cells.Add("ACCOUNT STATEMENT");
        headerTitleCell.ColSpan = 5;
        headerTitleCell.BackgroundColor = Color.FromArgb(69, 102, 158);
        headerTitleCell.DefaultCellTextState.ForegroundColor = Color.FromArgb(255, 255, 255);
        headerTitleCell.DefaultCellTextState.FontSize = 11;
        headerTitleCell.DefaultCellTextState.FontStyle = FontStyles.Bold;
        headerTitleCell.DefaultCellTextState.HorizontalAlignment = HorizontalAlignment.Center;
        ///

        headerTable.DefaultCellTextState = headerInfo;
        Aspose.Pdf.Cell headerCell;

        Aspose.Pdf.Row headerRow1 = headerTable.Rows.Add();
        headerCell = headerRow1.Cells.Add("");
        headerCell.ColSpan = 5;

        Aspose.Pdf.Row headerRow2 = headerTable.Rows.Add();
        headerCell = headerRow2.Cells.Add(request.Client.FullName);
        headerCell.ColSpan = 3;
        headerCell = headerRow2.Cells.Add("Date:");
        headerCell = headerRow2.Cells.Add(request.DateTime.ToString()); //"2020/08/01 06:03:47"
        headerCell.DefaultCellTextState = rightText;

        Aspose.Pdf.Row headerRow3 = headerTable.Rows.Add();
        headerCell = headerRow3.Cells.Add("210 AMARAND AVENUE");
        headerCell.ColSpan = 3;
        headerCell = headerRow3.Cells.Add("Enquiries:");
        headerCell = headerRow3.Cells.Add("");
        headerCell.DefaultCellTextState = rightText;

        Aspose.Pdf.Row headerRow4 = headerTable.Rows.Add();
        headerCell = headerRow4.Cells.Add("MENLYN");
        headerCell.ColSpan = 3;
        headerCell = headerRow4.Cells.Add("Local:");
        headerCell = headerRow4.Cells.Add("080 23 23 23 6");
        headerCell.DefaultCellTextState = rightText;

        Aspose.Pdf.Row headerRow5 = headerTable.Rows.Add();
        headerCell = headerRow5.Cells.Add("PRETORIA");
        headerCell.ColSpan = 3;
        headerCell = headerRow5.Cells.Add("International:");
        headerCell = headerRow5.Cells.Add("+27 80 23 23 23 6");
        headerCell.DefaultCellTextState = rightText;

        Aspose.Pdf.Row headerRow6 = headerTable.Rows.Add();
        headerCell = headerRow6.Cells.Add("GAUTENG");
        headerCell.ColSpan = 3;
        headerCell = headerRow6.Cells.Add("");
        headerCell = headerRow6.Cells.Add("");
        headerCell.DefaultCellTextState = rightText;

        Aspose.Pdf.Row headerRow7 = headerTable.Rows.Add();
        headerCell = headerRow7.Cells.Add("SOUTH AFRICA");
        headerCell.ColSpan = 3;
        headerCell = headerRow7.Cells.Add("");
        headerCell = headerRow7.Cells.Add("");
        headerCell.DefaultCellTextState = rightText;

        Aspose.Pdf.Row headerRow8 = headerTable.Rows.Add();
        headerCell = headerRow8.Cells.Add("0002");
        headerCell.ColSpan = 3;
        headerCell = headerRow8.Cells.Add("");
        headerCell = headerRow8.Cells.Add("");
        headerCell.DefaultCellTextState = rightText;

        Aspose.Pdf.Row spacer1 = headerTable.Rows.Add();
        headerCell = spacer1.Cells.Add("");
        headerCell.ColSpan = 5;

        Aspose.Pdf.Row headerRow9 = headerTable.Rows.Add();
        headerCell = headerRow9.Cells.Add("");
        headerCell.ColSpan = 3;
        headerCell = headerRow9.Cells.Add("Current Balance:");
        headerCell = headerRow9.Cells.Add("78,050.08");
        headerCell.DefaultCellTextState = rightText;

        Aspose.Pdf.Row headerRow10 = headerTable.Rows.Add();
        headerCell = headerRow10.Cells.Add("");
        headerCell.ColSpan = 3;
        headerCell = headerRow10.Cells.Add("Available Balance:");
        headerCell = headerRow10.Cells.Add(request.Client.AvailableBalance.ToString());
        headerCell.DefaultCellTextState = rightText;

        Aspose.Pdf.Row spacer2 = headerTable.Rows.Add();
        headerCell = spacer2.Cells.Add("");
        headerCell.ColSpan = 5;

        Aspose.Pdf.Row headerRow11 = headerTable.Rows.Add();
        headerCell = headerRow11.Cells.Add("Account Details");
        headerCell.ColSpan = 5;

        Aspose.Pdf.Row headerRow12 = headerTable.Rows.Add();
        headerCell = headerRow12.Cells.Add("Product: " + request.Client.ProductName);
        headerCell.ColSpan = 5;

        Aspose.Pdf.Row headerRow13 = headerTable.Rows.Add();
        headerCell = headerRow13.Cells.Add("Account Number: " + request.Client.AccountNumber);
        headerCell.ColSpan = 5;

        Aspose.Pdf.Row headerRow14 = headerTable.Rows.Add();
        headerCell = headerRow14.Cells.Add("Branch Code: " + "683000");
        headerCell.ColSpan = 5;

        // Create a Header Section of the PDF file
        Aspose.Pdf.HeaderFooter header = new Aspose.Pdf.HeaderFooter();
        // Set the Odd Header for the PDF file
        page.Header = header;

        // Set the top margin for the header section
        header.Margin.Top = 20;
        header.Margin.Right = 25;
        header.Margin.Left = 25;

        // Create a Footer Section of the PDF file
        ////
        Aspose.Pdf.HeaderFooter footer = new Aspose.Pdf.HeaderFooter();
        // Set the Odd Header for the PDF file
        page.Footer = footer;

        // Set the top margin for the header section
        footer.Margin.Bottom = 5;
        footer.Margin.Right = 25;
        footer.Margin.Left = 25;


        //////////////
        ///
        Aspose.Pdf.Table footerTable = new Table
        {
            ColumnWidths = "180 100 80 95 95"
        };


        // Set the default cell padding to the MarginInfo object
        footerTable.DefaultCellTextState = footerText;

        Aspose.Pdf.Row footerRow = footerTable.Rows.Add();
        Aspose.Pdf.Cell footerCell;
        footerCell = footerRow.Cells.Add("Sasfin Bank Limited");
        footerCell.ColSpan = 5;
        footerCell.DefaultCellTextState = rightText;

        Aspose.Pdf.Row footerRow1 = footerTable.Rows.Add();
        footerCell = footerRow1.Cells.Add("Reg no. 1951/002280/06 info@sasfin.com");
        footerCell.ColSpan = 5;
        footerCell.DefaultCellTextState = rightText;

        Aspose.Pdf.Row footerRow2 = footerTable.Rows.Add();
        footerCell = footerRow2.Cells.Add("29 Scott Street Waverley Johannesburg 2090 PO Box 95104 Grant Park 2051");
        footerCell.ColSpan = 5;
        footerCell.DefaultCellTextState = rightText;

        Aspose.Pdf.Row footerRow3 = footerTable.Rows.Add();
        footerCell = footerRow3.Cells.Add("Tel: +27 11 809 7500 Fax: +27 11 887 6167");
        footerCell.ColSpan = 5;
        footerCell.DefaultCellTextState = rightText;

        Aspose.Pdf.Row footerRow4 = footerTable.Rows.Add();
        footerCell = footerRow4.Cells.Add("Also at Bloemfontein Cape Town Durban Hong Kong Plettenberg Bay Port Elizabeth Pretoria");
        footerCell.ColSpan = 5;
        footerCell.DefaultCellTextState = rightText;

        Aspose.Pdf.Row footerRow5 = footerTable.Rows.Add();
        footerCell = footerRow5.Cells.Add("An authorised financial services provider licence no. 23833, registered credit provider NCRCP22 and a member of the Sasfin Group");
        footerCell.ColSpan = 5;
        footerCell.DefaultCellTextState = rightText;

        ///

        //Header code end

        Aspose.Pdf.MarginInfo CellPadding = new Aspose.Pdf.MarginInfo
        {
            Top = 5,
            Bottom = 4,
            Left = 5,
            Right = 5
        };

        Aspose.Pdf.MarginInfo footerPadding = new Aspose.Pdf.MarginInfo
        {
            Top = 2,
            Bottom = 0,
            Left = 0,
            Right = 0
        };

        pdfTable.DefaultCellPadding = CellPadding;
        interestPdfTable.DefaultCellPadding = CellPadding;
        closingPdfTable.DefaultCellPadding = CellPadding;
        headerTitleTable.DefaultCellPadding = CellPadding;
        headerTable.DefaultCellPadding = headerCellPadding;
        footerTable.DefaultCellPadding = footerPadding;

        page.Paragraphs.Add(pdfTable);
        page.Paragraphs.Add(spacerPdfTable);
        page.Paragraphs.Add(interestPdfTable);
        page.Paragraphs.Add(spacerPdfTableNB);
        page.Paragraphs.Add(closingPdfTable);
        header.Paragraphs.Add(headerTitleTable);
        header.Paragraphs.Add(headerTable);
        footer.Paragraphs.Add(footerTable);

        MemoryStream outStream = new MemoryStream();
        doc.Save(outStream, SaveFormat.Pdf);
        //doc.Save(outStream, SaveFormat.Pdf);
        //byte[] docBytes = outStream.ToArray();


        //Stream streamA = new MemoryStream(docBytes);

        //Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(streamA);
        //Stream stream = new MemoryStream();
        //pdfDoc.Save(stream);


        var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
        response.Content = new StreamContent(outStream);
        response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");
        response.Content.Headers.Add("Content-Disposition", string.Format("attachment; filename={0}{1}.pdf", "MonthlyAccountStatement_", accountNumber));
        return response;

        //dataDir = dataDir + "CreateMultiColumnPdf_out.pdf";
        // Save PDF file
        //doc.Save(dataDir);
        // ExEnd:CreateMultiColumnPdf            
        //Console.WriteLine("\nMulti column pdf file created successfully.\nFile saved at " + dataDir);

    }

}

}

@Embrose

We tried to use your code snippet and found that it has missing definitions of some objects e.g. Transactions, etc. However, we tested the scenario using following simple code snippet in a console application with Aspose.PDF for .NET 20.8. We were unable to notice the issue you have mentioned.

Document doc = new Document(); 
doc.Pages.Add();
doc.Pages.Add();
doc.Pages[1].Paragraphs.Add(new TextFragment("Page $p of $P"));
doc.Pages[2].Paragraphs.Add(new TextFragment("Page $p of $P"));
doc.Save(dataDir + "PageNumbers.pdf");

PageNumbers.pdf (2.1 KB)

Could you please make sure to use latest version of the API. In case issue still persists, please share a simple runnable code snippet which can replicate the issue in our environment. We will again test it and address it accordingly.