Skip to content

Commit ff78a69

Browse files
Merge pull request #271 from SyncfusionExamples/1046084
1046084: Added Sample GitHub code for Missing PDF UG Topics
2 parents 41c9994 + 34919c4 commit ff78a69

31 files changed

Lines changed: 296 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Flatten-Redaction-Annotation/Flatten-Redaction-Annotation.csproj" />
3+
</Solution>
Binary file not shown.
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>Flatten_Redaction_Annotation</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>

Annotation/Flatten-Redaction-Annotation/.NET/Flatten-Redaction-Annotation/Output/.gitkeep

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Syncfusion.Pdf.Interactive;
2+
using Syncfusion.Pdf.Parsing;
3+
using Syncfusion.Pdf.Redaction;
4+
5+
//Load the PDF document.
6+
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(Path.GetFullPath(@"Data/Input.pdf")))
7+
{
8+
//Get the annotation from annotation collection.
9+
foreach (PdfAnnotation annot in loadedDocument.Pages[0].Annotations)
10+
{
11+
//Check for the Redaction annotation.
12+
if (annot is PdfLoadedRedactionAnnotation)
13+
{
14+
//Get the redaction annotation.
15+
PdfLoadedRedactionAnnotation redactAnnot = annot as PdfLoadedRedactionAnnotation;
16+
//Flatten the redaction annotation.
17+
redactAnnot.Flatten = true;
18+
}
19+
}
20+
loadedDocument.Redact();
21+
//Save the document
22+
loadedDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
23+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Retrieve-Custom-PDF-Annotation-Values/Retrieve-Custom-PDF-Annotation-Values.csproj" />
3+
</Solution>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Syncfusion.Pdf;
2+
using Syncfusion.Pdf.Interactive;
3+
using Syncfusion.Pdf.Parsing;
4+
5+
// Load the PDF document
6+
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(Path.GetFullPath(@"Data/Input.pdf")))
7+
{
8+
// Get the first page of the document
9+
PdfLoadedPage page = loadedDocument.Pages[0] as PdfLoadedPage;
10+
// Get the annotation collection from the page
11+
PdfLoadedAnnotationCollection annotations = page.Annotations;
12+
// Get the first annotation (assumed to be a rectangle annotation)
13+
PdfLoadedRectangleAnnotation annot = annotations[8] as PdfLoadedRectangleAnnotation;
14+
// Try to get the custom value "Subtype" from the annotation
15+
object values;
16+
bool foundValue = annot.TryGetValue("Subtype", out values);
17+
// Check and print the values if found
18+
if (foundValue && values is List<string> stringValues)
19+
{
20+
foreach (string value in stringValues)
21+
{
22+
// Print the custom value to the console
23+
Console.WriteLine($"Found Subtype value: {value}");
24+
}
25+
}
26+
else
27+
{
28+
Console.WriteLine("Subtype value not found.");
29+
}
30+
}
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>Retrieve_Custom_PDF_Annotation_Values</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>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Managing-Form-Field-Visibility/Managing-Form-Field-Visibility.csproj" />
3+
</Solution>

0 commit comments

Comments
 (0)