How to Start Convert PDF Read PDF Edit PDF PDF Report Builder Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

C# PDF Generator Library
How to add Footnote and Endnote to PDF file in C# code


C# Demo Code to add Footnote and Endnote to adobe pdf file





In this C# tutorial, you will learn how to add, insert footnote and endnote content to PDF using C# in ASP.NET MVC Web, Windows applications.





Add a simple footnote to PDF using C#


The below C# source code will show how to add a simple footnote content to PDF document using C# code

  • Create a new PDF document and open for editing
  • Define a new Paragraph object
  • Use method Paragraph.AddChunk() to add new text to the text paragraph
  • Define a new Footnote object with text content, and add the object to the paragraph
  • Define a new Footnote object with text content, and add the object to the paragraph
  • Add the text paragraph object with text content and footnote to the PDF document
  • Save the PDF file with content modified



String outputFilePath = Program.RootPath + "\\" + "Sample81.pdf";

Document document = new Document();

PDFBuildHandler.Create(document, outputFilePath);

document.Open();
document.SetFootnoteInfo(new FootnoteSetting());

Paragraph p = new Paragraph();
p.AddChunk(new TextChunk("This is a sample for footnote"));

//  insert a footnote
Footnote footnote1 = new Footnote("This is the 1st footnote");
p.AddChunk(footnote1);

p.AddChunk(new TextChunk("."));

p.AddChunk(new TextChunk("This is a sample for the 2nd footnote"));

//  insert a footnote
Footnote footnote2 = new Footnote("This is the 2nd footnote");
p.AddChunk(footnote2);

p.AddChunk(new TextChunk("."));

document.Add(p);

document.Close();




Add a simple endnote to PDF file using C#


String outputFilePath = Program.RootPath + "\\" + "Sample82.pdf";

Document document = new Document();

PDFBuildHandler.Create(document, outputFilePath);

document.Open();
document.SetEndnoteInfo(new EndnoteSetting());

Paragraph p = new Paragraph();

p.AddChunk(new TextChunk("This is a sample for endnote"));

//  insert a endnote
Endnote endnote1 = new Endnote("This is the 1st endnote");
p.AddChunk(endnote1);

p.AddChunk(new TextChunk(". This is a sample for the 2nd endnote"));

//  insert a endnote
Endnote endnote2 = new Endnote("This is the 2nd endnote");
p.AddChunk(endnote2);

p.AddChunk(new TextChunk("."));

document.Add(p);

//  insert a new page
document.NewPage();

document.Add(new Paragraph("This is the 2nd page."));

document.Close();