Skip to content

Commit acb4fab

Browse files
committed
972104: Added the UG documentation for Support to add tags for the Nested list in the PDF document
1 parent 9d645c0 commit acb4fab

4 files changed

Lines changed: 123 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36221.1 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tagged-Nested-Ordered-Lists", "Tagged-Nested-Ordered-Lists\Tagged-Nested-Ordered-Lists.csproj", "{04561C02-EB81-40BE-A859-F01B29D64216}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{04561C02-EB81-40BE-A859-F01B29D64216}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{04561C02-EB81-40BE-A859-F01B29D64216}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{04561C02-EB81-40BE-A859-F01B29D64216}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{04561C02-EB81-40BE-A859-F01B29D64216}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {9E0E1714-72FB-4681-83C2-0BF4BEDA3E0C}
24+
EndGlobalSection
25+
EndGlobal
Binary file not shown.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using Syncfusion.Drawing;
2+
using Syncfusion.Pdf;
3+
using Syncfusion.Pdf.Graphics;
4+
using Syncfusion.Pdf.Lists;
5+
6+
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY");
7+
// Create a new PDF document
8+
PdfDocument document = new PdfDocument();
9+
10+
// Set the document title
11+
document.DocumentInformation.Title = "Nested List";
12+
13+
// Add a new page to the PDF
14+
PdfPage page = document.Pages.Add();
15+
PdfGraphics graphics = page.Graphics;
16+
SizeF size = page.Graphics.ClientSize;
17+
18+
//Get stream from the font file.
19+
FileStream fontStream = new FileStream(Path.GetFullPath(@"Data/Arial.ttf"), FileMode.Open, FileAccess.Read);
20+
PdfFont font = new PdfTrueTypeFont(fontStream, 14);
21+
22+
// Draw the title on the PDF
23+
graphics.DrawString("Nested Ordered List:", font, PdfBrushes.Blue, new PointF(10, 0));
24+
25+
// Create a string format for line spacing of list items
26+
PdfStringFormat format = new PdfStringFormat();
27+
format.LineSpacing = 10f;
28+
29+
// Create the main list structure element with a List tag for accessibility
30+
PdfStructureElement mainListElement = new PdfStructureElement(PdfTagType.List);
31+
32+
// Initialize the main ordered list
33+
PdfOrderedList mainList = new PdfOrderedList
34+
{
35+
PdfTag = mainListElement,
36+
Marker = { Brush = PdfBrushes.Black },
37+
Indent = 20,
38+
Font = font,
39+
StringFormat = format
40+
};
41+
42+
// Add items to the main list and tag each item for accessibility
43+
string[] mainItems = { "Essential Tools", "Essential PDF", "Essential XlsIO" };
44+
for (int i = 0; i < mainItems.Length; i++)
45+
{
46+
mainList.Items.Add(mainItems[i]);
47+
mainList.Items[i].PdfTag = new PdfStructureElement(PdfTagType.ListItem);
48+
}
49+
50+
// Create a sublist with accessibility tags
51+
PdfStructureElement subListElement = new PdfStructureElement(PdfTagType.List);
52+
PdfOrderedList subList = new PdfOrderedList
53+
{
54+
PdfTag = subListElement,
55+
Marker = { Brush = PdfBrushes.Black },
56+
Indent = 20,
57+
Font = font,
58+
StringFormat = format
59+
};
60+
61+
// Add items to the sublist and tag each item for accessibility
62+
string[] subItems = { "Create PDF", "Modify PDF", "Secure PDF", "Compress PDF" };
63+
for (int i = 0; i < subItems.Length; i++)
64+
{
65+
subList.Items.Add(subItems[i]);
66+
subList.Items[i].PdfTag = new PdfStructureElement(PdfTagType.ListItem);
67+
}
68+
69+
// Nest the sublist under the second item of the main list
70+
mainList.Items[1].SubList = subList;
71+
72+
// Draw the main list, which includes the nested sublist, on the PDF
73+
mainList.Draw(page, new RectangleF(0, 30, size.Width, size.Height));
74+
75+
//Create file stream.
76+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
77+
{
78+
//Save the PDF document to file stream.
79+
document.Save(outputFileStream);
80+
}
81+
82+
//Close the document.
83+
document.Close(true);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Tagged_Nested_Ordered_Lists</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
</Project>

0 commit comments

Comments
 (0)