Articles in this section
Category / Section

How to draw Unordered list in WinForms PDF using C# and VB.NET?

5 mins read

The Syncfusion Essential® PDF is a feature-rich and high-performance our Winforms PDF feature tour page that is used to create, read, and edit PDF documents programmatically without Adobe dependencies. Using this library, you can draw an Unordered list in a PDF using C# and VB.NET.

Steps to draw an Unordered list in a PDF using C# programmatically

1. Create a new C# console application project.

create a console application2. Install the Syncfusion.PDF.WinForms NuGet packages as a reference to your .NET Framework application from NuGet.org.

Install nuget packages

3. Include the following namespaces in the Program.cs file.

C#

using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Lists;

 

VB.NET

Imports Syncfusion.Pdf
Imports Syncfusion.Pdf.Graphics
Imports Syncfusion.Pdf.Lists

4. The following code example shows how to draw an Unordered list in a PDF using C#.

C#

//Create a new instance of the PdfDocument class.
 
PdfDocument document = new PdfDocument();
 
//Add a new page to the document.
 
PdfPage page = document.Pages.Add();
 
PdfGraphics graphics = page.Graphics;
 
SizeF size = page.Graphics.ClientSize;
 
//Create an unordered list
 
PdfUnorderedList list = new PdfUnorderedList();
 
//Set the marker style
 
list.Marker.Style = PdfUnorderedMarkerStyle.Disk;
 
//Create font and write the title
 
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
 
//Create a string format
 
PdfStringFormat format = new PdfStringFormat();
 
format.LineSpacing = 10f;
 
// Format list
 
list.Font = font;
 
list.StringFormat = format;
 
//Set the list indent
 
list.Indent = 10;
 
//Add items to the list
 
list.Items.Add("PDF");
 
list.Items.Add("XlsIO");
 
list.Items.Add("DocIO");
 
list.Items.Add("PPT");
 
//Set the text-indent
 
list.TextIndent = 10;
 
//Draw a list
 
list.Draw(page, new RectangleF(0, 10, size.Width, size.Height));
 
// Save and close the document.
 
document.Save("Output.pdf");
 
document.Close(true);

VB.NET

'Create a new instance of the PdfDocument class.
 
Dim document As New PdfDocument()
 
'Add a new page to the document.
 
Dim page As PdfPage = document.Pages.Add()
 
Dim graphics As PdfGraphics = page.Graphics
 
Dim size As SizeF = page.Graphics.ClientSize
 
'Create an unordered list
 
Dim list As New PdfUnorderedList()
 
'Set the marker style
 
list.Marker.Style = PdfUnorderedMarkerStyle.Disk
 
'Create font and write the title
 
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
 
'Create a string format
 
Dim format As New PdfStringFormat()
 
format.LineSpacing = 10.0F
 
' Format list
 
list.Font = font
 
list.StringFormat = format
 
'Set a list indent
 
list.Indent = 10
 
'Add items to the list
 
list.Items.Add("PDF")
 
list.Items.Add("XlsIO")
 
list.Items.Add("DocIO")
 
list.Items.Add("PPT")
 
'Set the text-indent
 
list.TextIndent = 10
 
'Draw a list
 
list.Draw(page, New RectangleF(0, 10, size.Width, size.Height))
 
'Save and close the document.
 
document.Save("Output.pdf")
 
document.Close(True)

A complete working sample can be downloaded from PdfSampleList.zip.

By executing the program, you will get the PDF document as follows.

output screenshot

Take a moment to peruse the documentation. You can find the options like add an ordered or unordered list in a PDF document, the styles can be bullets, circle, or an image.

Refer to herehere to explore a rich set of Syncfusion Essential® PDF features.

Note:

Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without trail message.


See Also:

Working with Text | Syncfusion

How to draw grid in a PDF using C# and VB.NET in WinForms?

How to draw shapes in a PDF using C# and VB.NET?

Conclusion

I hope you enjoyed learning about how to draw Unordered list in WinForms PDF using C# and VB.NET.

You can refer to our Winforms PDF feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied