Add header and footer for an existing pdf file

Hi
I need to add header and footer for an existing pdf file.In the header and footer i want to add a table with multiple rows and columns with text and images inside the cell.I am able to add in aspose.words.
Can you Please provide code samples.

Thanks & Regards
Jegadeesh S

@mhorg,

Thanks for your inquiry. Your query is related to Aspose.Pdf API. I am moving this forum thread to Aspose.Pdf forum where you’ll be guided appropriately.

@mhorg,

The Header and Footer members of the Page class allows to add content in the header and footer of the PDF document. Please try the following code example:

[C#]

string dataDir = @"C:\Pdf\test516\";
            
//Instantiate PDF instance by calling empty constructor
Document document = new Document();
//Create a section in the pdf document
Aspose.Pdf.Page page1 = document.Pages.Add();

// Create a Header Section of the PDF file
Aspose.Pdf.HeaderFooter header = new Aspose.Pdf.HeaderFooter();
//Instantiate a table object
Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
tab1.HorizontalAlignment = HorizontalAlignment.Center;
header.Paragraphs.Add(tab1);
tab1.ColumnWidths = "100";

//Create rows in the table and then cells in the rows
Aspose.Pdf.Row row1 = tab1.Rows.Add();
row1.Cells.Add("row 1 column 1").Alignment = HorizontalAlignment.Center;
row1.Cells.Add("row 1 column 2").Alignment = HorizontalAlignment.Center;
row1.Cells.Add("row 1 column 3").Alignment = HorizontalAlignment.Center;

Aspose.Pdf.Row row2 = tab1.Rows.Add();
row2.Cells.Add("row 1 column 1").Alignment = HorizontalAlignment.Center;
row2.Cells.Add("row 2 column 2").Alignment = HorizontalAlignment.Center;
row2.Cells.Add("row 3 column 3").Alignment = HorizontalAlignment.Center;

page1.Header = header;
document.Save(@"C:\Pdf\test517\Output.pdf", SaveFormat.Pdf);

This is the output PDF:

Output.pdf (2.0 KB)