Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36221.1 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Setting-Section-Page-Numbers-With-Custom-Styles", "Setting-Section-Page-Numbers-With-Custom-Styles\Setting-Section-Page-Numbers-With-Custom-Styles.csproj", "{73050DDC-B7A3-48AC-AAF9-72B3710424DC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{73050DDC-B7A3-48AC-AAF9-72B3710424DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73050DDC-B7A3-48AC-AAF9-72B3710424DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73050DDC-B7A3-48AC-AAF9-72B3710424DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73050DDC-B7A3-48AC-AAF9-72B3710424DC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BD540509-74DF-4C8F-9D94-6D807B315F6C}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Drawing;

class Program
{
static void Main(string[] args)
{
//Create a new document.
PdfDocument document = new PdfDocument();

//Add a section to the document.
PdfSection section = document.Sections.Add();

//Set the font for the page number.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);

//Create a section page number field.
PdfSectionPageNumberField sectionPageNumber = new PdfSectionPageNumberField();

//Set the page number style to LowerRoman (i, ii, iii, etc.).
sectionPageNumber.NumberStyle = PdfNumberStyle.LowerRoman;
sectionPageNumber.Font = font;

//Add pages to the section and draw the page number field in the footer.
for (int i = 0; i < 3; i++)
{
//Add a new page to the section.
PdfPage page = section.Pages.Add();

//Get the page's client size to calculate the footer position.
SizeF pageSize = page.GetClientSize();

//Define the position for the page number in the footer (bottom-right).
PointF footerPosition = new PointF(pageSize.Width - 50, pageSize.Height - 20);

//Draw the section page number at the calculated footer position.
sectionPageNumber.Draw(page.Graphics, footerPosition);

// You can add other content to the main body of the page here.
// For example, let's draw text at the top, leaving space for the footer.
page.Graphics.DrawString("This is the main content of a page with a footer.", font, PdfBrushes.Black, new PointF(10, 10));
}

//Create file stream.
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
{
//Save the PDF document to file stream.
document.Save(outputFileStream);
}

//Close the document.
document.Close(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Setting-Section-Page-Numbers-With-Custom-Styles</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" />
</ItemGroup>

</Project>
Loading