Skip to content

Commit 6136274

Browse files
committed
923636: Added code sample for set section page numbers with custom styles in PDFs
1 parent 6a9a85f commit 6136274

4 files changed

Lines changed: 68 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}") = "Add-roman-page-numbers-to-PDF-sections", "Add-roman-page-numbers-to-PDF-sections\Add-roman-page-numbers-to-PDF-sections.csproj", "{73050DDC-B7A3-48AC-AAF9-72B3710424DC}"
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+
{73050DDC-B7A3-48AC-AAF9-72B3710424DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{73050DDC-B7A3-48AC-AAF9-72B3710424DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{73050DDC-B7A3-48AC-AAF9-72B3710424DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{73050DDC-B7A3-48AC-AAF9-72B3710424DC}.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 = {BD540509-74DF-4C8F-9D94-6D807B315F6C}
24+
EndGlobalSection
25+
EndGlobal
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>Add_roman_page_numbers_to_PDF_sections</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>

Pages/Add-roman-page-numbers-to-PDF-sections/.NET/Add-roman-page-numbers-to-PDF-sections/Output/gitkeep.txt

Whitespace-only changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Syncfusion.Pdf;
2+
using Syncfusion.Pdf.Graphics;
3+
4+
//Create a new document.
5+
PdfDocument document = new PdfDocument();
6+
//Add the section.
7+
PdfSection section = document.Sections.Add();
8+
//Set the font.
9+
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
10+
//Create section page number field.
11+
PdfSectionPageNumberField sectionPageNumber = new PdfSectionPageNumberField();
12+
sectionPageNumber.NumberStyle = PdfNumberStyle.LowerRoman;
13+
sectionPageNumber.Font = font;
14+
//Draw the sectionPageNumber in section.
15+
for (int i = 0; i < 3; i++)
16+
{
17+
PdfPage page = section.Pages.Add();
18+
sectionPageNumber.Draw(page.Graphics);
19+
page.Graphics.DrawString("This code is a practical example of how to automatically add Roman numeral page numbers", font, PdfBrushes.Black, new Syncfusion.Drawing.PointF(10, 0));
20+
}
21+
//Create file stream.
22+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
23+
{
24+
//Save the PDF document to file stream.
25+
document.Save(outputFileStream);
26+
}
27+
//Close the document.
28+
document.Close(true);

0 commit comments

Comments
 (0)