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 Report Generator Library
How to add a list of text to PDF report file using C#?


C# Demo Code to add a list to adobe pdf file





In this C# tutorial, you will learn how to insert styled list text to a new PDF report file using C# in ASP.NET MVC Web, Windows applications.

  • Add, insert numbered or unnumbered list to PDF
  • Custumize the list symbol, item indentation to the list of PDF document





Add a unnumbered list to a PDF report document using C#


The C# sample source code below, will show how to add unnumbered text list to a new PDF report file using C# in ASP.NET MVC Web, Windows applications.

  • Create a new PDF report file using PDFBuildHandler.Create()
  • Call method Document.Open() to start editing content in PDF document
  • Create a list of ListItem objects with item text content
  • Insert the list to the PDF document
  • Call method Document.Close() to apply the document changes and save to the output PDF file



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

Document document = new Document();
PDFBuildHandler.Create(document, outputFilePath);

//  open document
document.Open();

//  initial a unnumbered list
List list = new List(false);
for (int i = 0; i < 5; i++)
{
    ListItem listItem = new ListItem("This is list item " + i + ".");
    list.Add(listItem);
}

//  add list to the document
document.Add(list);

//  close document and save to the output file
document.Close();




Add a numbered list to PDF using C#


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

Document document = new Document();
PDFBuildHandler.Create(document, outputFilePath);

//  open document
document.Open();

//  initial a numbered list
List list = new List(true);
for (int i = 0; i < 5; i++)
{
    ListItem listItem = new ListItem("This is list item " + i + ".");
    list.Add(listItem);
}

//  add list to the document
document.Add(list);

//  close document and save to the output file
document.Close();




Use letter as list symbol for a list on PDF document in C# code


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

Document document = new Document();
PDFBuildHandler.Create(document, outputFilePath);

//  open document
document.Open();

//  initial a unnumbered list
List list1 = new List(false, false);
for (int i = 0; i < 3; i++)
{
    ListItem listItem = new ListItem("Unnumbered list: Item " + i + ".");
    list1.Add(listItem);
}

//  initial a numbered list
List list2 = new List(true, false);
for (int i = 0; i < 3; i++)
{
    ListItem listItem = new ListItem("Numbered list: Item " + i + ".");
    list2.Add(listItem);
}

//  initial a unnumbered list
List list3 = new List(false, true);
for (int i = 0; i < 3; i++)
{
    ListItem listItem = new ListItem("Unnumbered list (Letter): Item " + i + ".");
    list3.Add(listItem);
}

//  initial a numbered list
List list4 = new List(true, true);
for (int i = 0; i < 3; i++)
{
    ListItem listItem = new ListItem("Numbered list (Letter): Item " + i + ".");
    list4.Add(listItem);
}


//  add lists to the document
document.Add(list1);
document.Add(list2);
document.Add(list3);
document.Add(list4);

//  close document and save to the output file
document.Close();




Change symbol indent for a list on PDF using C#


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

Document document = new Document();
PDFBuildHandler.Create(document, outputFilePath);

//  open document
document.Open();

float symbolIndent = 2F;
//  initial a numbered list
List list1 = new List(true, symbolIndent);
for (int i = 0; i < 3; i++)
{
    ListItem listItem = new ListItem("List item " + i + ".");
    list1.Add(listItem);
}

symbolIndent = 4F;
//  initial a numbered list
List list2 = new List(true, symbolIndent);
for (int i = 0; i < 3; i++)
{
    ListItem listItem = new ListItem("List item " + i + ".");
    list2.Add(listItem);
}

symbolIndent = 6F;
//  initial a numbered list
List list3 = new List(true, symbolIndent);
for (int i = 0; i < 3; i++)
{
    ListItem listItem = new ListItem("List item " + i + ".");
    list3.Add(listItem);
}

//  add list to the document
document.Add(list1);
document.Add(list2);
document.Add(list3);

//  close document and save to the output file
document.Close();