Skip to content

Commit f41ca57

Browse files
committed
1006332: How can I remove headers and footers with the Syncfusion PDF library
1 parent c28924a commit f41ca57

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-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="Remove-headers-and-footers-from-the-pdf-document/Remove-headers-and-footers-from-the-pdf-document.csproj" />
3+
</Solution>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Syncfusion.Drawing;
2+
using Syncfusion.Pdf;
3+
using Syncfusion.Pdf.Parsing;
4+
using Syncfusion.Pdf.Redaction;
5+
6+
// Load the PDF document
7+
8+
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(Path.GetFullPath(@"Data/HeadersAndFooters.pdf")))
9+
{
10+
11+
PdfLoadedPage page1 = loadedDocument.Pages[0] as PdfLoadedPage;
12+
13+
float width = page1.Size.Width;
14+
15+
float height = page1.Size.Height;
16+
17+
//Create a redaction object
18+
19+
PdfRedaction redaction = new PdfRedaction(new RectangleF(520, height - 90, width, 50));
20+
21+
//Add a redaction object into the redaction collection of loaded page
22+
23+
page1.AddRedaction(redaction);
24+
25+
//Redact the contents from the PDF document
26+
27+
loadedDocument.Redact();
28+
29+
//Save the PDF document
30+
31+
loadedDocument.Save(Path.GetFullPath("Output/Output.pdf"));
32+
}
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>Remove_headers_and_footers_from_the_pdf_document</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Pdf.Imaging.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
</Project>

0 commit comments

Comments
 (0)