With bullets and numbering, you can make your document hierarchy clearer, more organized, and easier to focus on. In the process of editing the document, I personally also prefer the item label to highlight the article key information. In the previous article, you described how to create a list of project labels and numbers in Word, and in this article, we'll cover the ways to create PDF bulleted lists and multilevel numbered lists.
with Tools: Free spire.pdf for. NET
PS: DLLs can be obtained directly from the Bin folder under the installation path.
1. Create PDF Symbol list C
Using system;using system.drawing;using spire.pdf;using spire.pdf.graphics;using spire.pdf.lists;namespace Createlist_pdf{class Program {static void Main (string[] args) {//Create a PDF document Pd Fdocument doc = new pdfdocument (); Add a page A4 the size of page pdfpagebase page = doc. Pages.Add (PDFPAGESIZE.A4); Float y = 10; Create a title and format it, including font, font size, color pdfbrush brush1 = pdfbrushes.black; Pdftruetypefont font1 = new Pdftruetypefont (New Font ("Italic", 18f, Fontstyle.regular), true); Pdfstringformat format1 = new Pdfstringformat (pdftextalignment.center); Page. Canvas.drawstring ("Categories list", Font1, Brush1, page.) Canvas.clientsize.width/2, y, FORMAT1); y = y + font1. MeasureString ("Categories list", FORMAT1). Height; y = y + 5; Create list text and format RectangleF RCTG = new RectangleF (new PointF (0, 0), page. Canvas.clientsize); PdflineargraDientbrush brush = new Pdflineargradientbrush (RCTG, Color.steelblue, Color.Blue, Pdflineargradientmode.vert ical); Pdftruetypefont Font2 = new Pdftruetypefont (New Font ("Arial", 15f, Fontstyle.regular), true); String formatted = "Part 1 Listening" (hearing section) \ n Part 2 Speaking (colloquial portion) \ n 3 Reading (reading section) \ n Part 4 Writi Ng (Writing section) "+" \ n Part 5 test (test) 1 \ n Part 6 test (test) 2 \ n-7 test Answers (Test answer) "; Create a Pdflist class object and set the list and style pdflist lists = new pdflist (formatted); List. Font = Font2; List. Indent = 8; List. Textindent = 5; List. Brush = brush; Pdflayoutresult result = list. Draw (page, 0, y); y = result. Bounds.bottom; Save and open document Doc. SaveToFile ("List.pdf"); System.Diagnostics.Process.Start ("List.pdf"); } }}
Test results:
vb.net
Imports systemimports system.drawingimports spire.pdfimports Spire.Pdf.GraphicsImports Spire.Pdf.ListsNamespace Createlist_pdf Class program Private Shared Sub Main (ByVal args as String ()) Dim doc as Pdfdocument = New pdfdocument () Dim page as Pdfpagebase = Doc. Pages.Add (pdfpagesize.a4) Dim y As Single = ten Dim brush1 as Pdfbrush = Pdfbrushes.black Dim font1 As Pdftruetypefont = new Pdftruetypefont (New Font ("Italic", 18F, Fontstyle.regular), True) Dim format1 As Pdfstringformat = New Pdfstringformat (pdftextalignment.center) page. Canvas.drawstring ("Categories list", Font1, Brush1, page.) Canvas.clientsize.width/2, y, format1) y = y + font1. MeasureString ("Categories list", FORMAT1). Height y = y + 5 Dim rctg as RectangleF = new RectangleF (new PointF (0, 0), page. canvas.clientsize) Dim brush as Pdflineargradientbrush = New Pdflineargradientbrush (RCTG, CoLor. Steelblue, Color.Blue, pdflineargradientmode.vertical) Dim font2 as Pdftruetypefont = new Pdftruetypefont (New F Ont ("Arial", 15F, Fontstyle.regular), True) Dim formatted as String = "Part 1 Listening (hearing section)" & vblf & " Part 2 Speaking (colloquial section) "& vblf &" Part 3 Reading (Reading section) "& vblf &" Part 4 Writing (writing section) "& vblf &am P "Part 5 test (testing) 1" & vblf & "Part 6 test (test) 2" & vblf & "Part 7 Test Answers (Test answer)" Dim List as Pdflist = New pdflist (formatted) list. Font = Font2 list. Indent = 8 list. textindent = 5 list. Brush = Brush Dim result as Pdflayoutresult = list. Draw (page, 0, y) y = result. Bounds.bottom Doc. SaveToFile ("List.pdf") System.Diagnostics.Process.Start ("List.pdf") End Sub End Classend Namespace
2. Create a PDF multilevel numbered list
Spire.Pdf.dll supports multiple types of numbering types
C
Using spire.pdf;using spire.pdf.graphics;using spire.pdf.lists;using system;using system.drawing;namespace List2{ Class Program {static void Main (string[] args) {//New PDF document and add a page A4 size blank page pdfdocum ent doc = new pdfdocument (); Pdfpagebase page = doc. Pages.Add (PDFPAGESIZE.A4); Float y = 10; Add a caption and set the text and format Pdfbrush brush1 = Pdfbrushes.black; Pdftruetypefont font1 = new Pdftruetypefont (New Font ("Arial", 18f, Fontstyle.regular), true); Pdfstringformat format1 = new Pdfstringformat (pdftextalignment.center); Page. Canvas.drawstring ("Catalogue list", Font1, Brush1, page.) Canvas.clientsize.width/2, y, FORMAT1); y = y + font1. MeasureString ("Catalogue list", FORMAT1). Height; y = y + 5; Add text and set the font RectangleF RCTG = new RectangleF (new PointF (0, 0), page. Canvas.clientsize); Pdflineargradientbrush brush = new Pdflineargradientbrush (RCTG, CoLor. Darkblue, Color.brown, pdflineargradientmode.vertical); Pdftruetypefont Font2 = new Pdftruetypefont (New Font ("Arial", 15f, Fontstyle.regular), true); String formatted1 = "The first chapter general introduction"; String Formatted2 = "The first section of economic Law Overview"; String formatted3 = "The second section of economic law subject"; String formatted4 = "Chapter II Corporate legal system"; Set numbering list style Pdforderedmarker Marker1 = new Pdforderedmarker (pdfnumberstyle.numeric, New Pdffont (pdffontfamily.he Lvetica, 15f)); Pdforderedmarker marker2 = new Pdforderedmarker (Pdfnumberstyle.lowerroman, New Pdffont (Pdffontfamily.helvetica, 12f)) ; Format the first-level numbered list pdfsortedlist List1 = new Pdfsortedlist (FONT2); List1. Indent = 0; List1. Textindent = 5; List1. Brush = brush; List1. Marker = Marker1; Format the second-level numbered list pdfsortedlist List2 = new Pdfsortedlist (FONT2); List2. Marker = Marker2; List2. Brush = brush; List2. Textindent = 10; Applies the numbered list format to the specified text Pdflistitem item = List1. Items.Add (formatted1); Item. sublist = List2; List2. Items.Add (FORMATTED2); List2. Items.Add (FORMATTED3); List1. Items.Add (FORMATTED4); Set PDF document layout and location pdftextlayout textlayout = new Pdftextlayout (); Textlayout.break = Pdflayoutbreaktype.fitpage; Textlayout.layout = pdflayouttype.paginate; List1. Draw (page, new PointF (0, y), textlayout); Save the file doc. SaveToFile ("Multilevel list. pdf"); System.Diagnostics.Process.Start ("Multilevel list. pdf"); } }}
Test results:
vb.net
Imports spire.pdfimports Spire.Pdf.GraphicsImports Spire.Pdf.ListsImports systemimports system.drawingnamespace List2 Class program Private Shared Sub Main (ByVal args as String ()) Dim doc as Pdfdocument = New PDFD Ocument () Dim page as Pdfpagebase = Doc. Pages.Add (pdfpagesize.a4) Dim y As Single = ten Dim brush1 as Pdfbrush = Pdfbrushes.black Dim font1 As Pdftruetypefont = new Pdftruetypefont (New Font ("Arial", 18F, Fontstyle.regular), True) Dim format1 As Pdfstringformat = New Pdfstringformat (pdftextalignment.center) page. Canvas.drawstring ("Catalogue list", Font1, Brush1, page.) Canvas.clientsize.width/2, y, format1) y = y + font1. MeasureString ("Catalogue list", FORMAT1). Height y = y + 5 Dim rctg as RectangleF = new RectangleF (new PointF (0, 0), page. canvas.clientsize) Dim brush as Pdflineargradientbrush = New Pdflineargradientbrush (RCTG, Color.darkblue, Color . Brown, Pdflineargradientmode.vertical) Dim Font2 as Pdftruetypefont = new Pdftruetypefont (New Font ("Arial", 15F, Fontstyle.regular), True Dim formatted1 As String = "Chapter One General Introduction" Dim formatted2 As String = "The first section of Economic Law Overview" Dim format Ted3 As String = "second section of economic law subject" Dim formatted4 As String = "Chapter II Corporate legal System" Dim marker1 as Pdforderedmarke r = New Pdforderedmarker (pdfnumberstyle.numeric, Newpdffont (Pdffontfamily.helvetica, 15F)) Dim Marker2 as Pdfor Deredmarker = New Pdforderedmarker (Pdfnumberstyle.lowerroman, Newpdffont (Pdffontfamily.helvetica, 12F)) Dim Lis T1 as Pdfsortedlist = New pdfsortedlist (font2) List1. Indent = 0 List1. textindent = 5 List1. Brush = Brush List1. Marker = Marker1 Dim list2 as Pdfsortedlist = New pdfsortedlist (font2) List2. Marker = Marker2 List2. Brush = Brush List2. Textindent = Ten Dim item as Pdflistitem = List1. Items.Add (foRMATTED1) Item. sublist = List2 List2. Items.Add (FORMATTED2) List2. Items.Add (FORMATTED3) List1. Items.Add (FORMATTED4) Dim textlayout as Pdftextlayout = New pdftextlayout () Textlayout.break = Pdfla Youtbreaktype.fitpage textlayout.layout = Pdflayouttype.paginate List1. Draw (page, New PointF (0, y), TextLayout) Doc. SaveToFile ("Multilevel list. pdf") System.Diagnostics.Process.Start ("Multilevel list. pdf") End Sub End Classend Namespace
This is all about creating a PDF project designator list and a multilevel numbered list. If you want to reprint, please indicate the source. Thanks for reading!
C#/vb.net Creating PDF bulleted lists and multilevel numbered lists