Skip to content

Commit 824c5b1

Browse files
committed
Task-263371- different margin on different pages
1 parent 2b87406 commit 824c5b1

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Dynamic-Page-Margins-in-PDF-Documents/Dynamic-Page-Margins-in-PDF-Documents.csproj" />
3+
</Solution>
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>Dynamic_Page_Margins_in_PDF_Documents</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/Dynamic-Page-Margins-in-PDF-Documents/Dynamic-Page-Margins-in-PDF-Documents/Output/.gitkeep

Whitespace-only changes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//Create a new PDF document.
2+
using Syncfusion.Pdf;
3+
using Syncfusion.Pdf.Graphics;
4+
using Syncfusion.Drawing;
5+
6+
PdfDocument document = new PdfDocument();
7+
8+
//Create a solid brush and standard font.
9+
PdfBrush brush = new PdfSolidBrush(Color.Black);
10+
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 14);
11+
12+
// Section – 1
13+
//Add new section to the document
14+
PdfSection section = document.Sections.Add();
15+
//Page-settings.
16+
section.PageSettings.Margins.All = 0.5f;
17+
section.PageSettings.Width = 300;
18+
section.PageSettings.Height = 400;
19+
20+
//Add a page and draw text.
21+
PdfPage page = section.Pages.Add();
22+
PdfGraphics g = page.Graphics;
23+
g.DrawString(
24+
"Essential PDF is a library with the capability to produce Adobe PDF files",
25+
font, brush,
26+
new RectangleF(0, 0, page.GetClientSize().Width - 20, page.GetClientSize().Height));
27+
28+
//Section – 2
29+
//Add new section to the document
30+
section = document.Sections.Add();
31+
section.PageSettings.Margins.All = 5f;
32+
section.PageSettings.Width = 300;
33+
section.PageSettings.Height = 400;
34+
35+
page = section.Pages.Add();
36+
g = page.Graphics;
37+
g.DrawString(
38+
"Essential PDF is a library with the capability to produce Adobe PDF files",
39+
font, brush,
40+
new RectangleF(0, 0, page.GetClientSize().Width - 20, page.GetClientSize().Height));
41+
42+
//Save and close the document.
43+
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
44+
document.Close(true);

0 commit comments

Comments
 (0)