Footer on subsequent pages random characters - Aspose.Pdf.Page.Footer

Hi Aspose support, I am testing code placing a HTML footer on the pages of a PDF using the Aspose.Pdf.Page.Footer property. It works for the first page in the document however the 2nd page has random characters and subsequent pages don’t have anything. Code is below as well as the source and output files.

        //Convert the file to PDF
        Aspose.Words.Document wordDoc = new Aspose.Words.Document(incomingFile);

        wordDoc.Save(outgoingFile);

        //Add in the header
        Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(outgoingFile);

        Aspose.Pdf.HeaderFooter pdfFooter = new Aspose.Pdf.HeaderFooter();

        pdfFooter.Margin = new Aspose.Pdf.MarginInfo
        {
            Top = 10,
            Bottom = 10,
            Left = 10,
            Right = 10
        };

        pdfFooter.Paragraphs.Add(new Aspose.Pdf.HtmlFragment("<html>Footer</html>"));

        foreach (Aspose.Pdf.Page page in pdfDoc.Pages)
        {
            page.Footer = pdfFooter;
        }

        pdfDoc.Save(outgoingFile);

HeaderFooterTestDocument_1.zip (49.8 KB)

@james.sales

Thanks for contacting support.

We have tested the scenario by modifying your code snippet a bit as following and managed to achieve correct output. Would you please use following code snippet and in case you still face any issue, please feel free to let us know.

//Convert the file to PDF
Aspose.Words.Document wordDoc = new Aspose.Words.Document(dataDir + "HeaderFooterTestDocument_1.docx");
wordDoc.Save(dataDir + "HeaderFooterTestDocument_1.pdf", Aspose.Words.SaveFormat.Pdf);
//Add in the header
Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(dataDir + "HeaderFooterTestDocument_1.pdf");
foreach (Aspose.Pdf.Page page in pdfDoc.Pages)
{
  Aspose.Pdf.HeaderFooter pdfFooter = new Aspose.Pdf.HeaderFooter();
  pdfFooter.Margin = new Aspose.Pdf.MarginInfo
  {
   Top = 10,
   Bottom = 10,
   Left = 10,
   Right = 10
  };
  page.Footer = pdfFooter;
  page.Footer.Paragraphs.Add(new Aspose.Pdf.HtmlFragment("<html>Footer</html>"));
}
pdfDoc.Save(dataDir + "HeaderFooterTestDocument_1.pdf");

HeaderFooterTestDocument_1.pdf (44.2 KB)

@asad.ali

Thanks for the updated code, it works perfectly!