How to Start Convert PDF Read PDF Build PDF 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

Using C# PDF SDK
C# PDF Builder: How to add a list of text to PDF file


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













Add a unnumbered list


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


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


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


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();