diff --git a/Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation.sln b/Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation.sln new file mode 100644 index 00000000..cb409362 --- /dev/null +++ b/Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Get-value-from-PDF-annotation", "Get-value-from-PDF-annotation\Get-value-from-PDF-annotation.csproj", "{B83CBD04-0016-419B-BD77-081A35DCF2EB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B83CBD04-0016-419B-BD77-081A35DCF2EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B83CBD04-0016-419B-BD77-081A35DCF2EB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B83CBD04-0016-419B-BD77-081A35DCF2EB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B83CBD04-0016-419B-BD77-081A35DCF2EB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation/Data/Input.pdf b/Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation/Data/Input.pdf new file mode 100644 index 00000000..cd365b6f Binary files /dev/null and b/Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation/Data/Input.pdf differ diff --git a/Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation/Get-value-from-PDF-annotation.csproj b/Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation/Get-value-from-PDF-annotation.csproj new file mode 100644 index 00000000..8d2268e9 --- /dev/null +++ b/Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation/Get-value-from-PDF-annotation.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Get_value_from_PDF_annotation + enable + enable + + + + + + + diff --git a/Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation/Program.cs b/Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation/Program.cs new file mode 100644 index 00000000..cd08b105 --- /dev/null +++ b/Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation/Program.cs @@ -0,0 +1,31 @@ +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf; + +// Load the existing PDF document using FileStream +using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read)) +{ + // Load the PDF document from the input stream + using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputStream)) + { + // Access the first page of the document + PdfLoadedPage page = loadedDocument.Pages[0] as PdfLoadedPage; + // Get the collection of annotations from the page + PdfLoadedAnnotationCollection annotations = page.Annotations; + + // Check if at least one annotation exists and it's a popup annotation + if (annotations.Count > 0 && annotations[0] is PdfLoadedPopupAnnotation annotation) + { + // Get the custom value from the annotation + List customValue = annotation.GetValues("custom"); + + foreach (string value in customValue) + { + // Print the custom value to the console + Console.WriteLine("Custom value from annotation: " + value); + } + } + // Close the document and release resources + loadedDocument.Close(true); + } +} diff --git a/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation.sln b/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation.sln new file mode 100644 index 00000000..ce746b97 --- /dev/null +++ b/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Set-value-from-PDF-annotation", "Set-value-from-PDF-annotation\Set-value-from-PDF-annotation.csproj", "{D4AF6325-8E64-4964-936E-4CA47FB892E4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D4AF6325-8E64-4964-936E-4CA47FB892E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D4AF6325-8E64-4964-936E-4CA47FB892E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D4AF6325-8E64-4964-936E-4CA47FB892E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D4AF6325-8E64-4964-936E-4CA47FB892E4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation/Data/Input.pdf b/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation/Data/Input.pdf new file mode 100644 index 00000000..75d86ebc Binary files /dev/null and b/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation/Data/Input.pdf differ diff --git a/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation/Output/gitkeep.txt b/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation/Program.cs b/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation/Program.cs new file mode 100644 index 00000000..0b3afbfc --- /dev/null +++ b/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation/Program.cs @@ -0,0 +1,34 @@ + +using Syncfusion.Pdf.Interactive; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf; + +// Load the existing PDF document using FileStream +using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read)) +{ + // Load the PDF document from the input stream + using (PdfLoadedDocument ldoc = new PdfLoadedDocument(inputStream)) + { + // Access the first page of the document + PdfLoadedPage page = ldoc.Pages[0] as PdfLoadedPage; + + // Get the collection of annotations from the page + PdfLoadedAnnotationCollection annotations = page.Annotations; + + // Check if at least one annotation exists and it's a popup annotation + if (annotations.Count > 0 && annotations[0] is PdfLoadedPopupAnnotation annotation) + { + // Set a custom key-value pair in the annotation's metadata + annotation.SetValues("custom", "This is the custom data for the annotation"); + } + + // Save the modified document using a new FileStream + using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.Write)) + { + // Save changes to a new PDF file + ldoc.Save(outputStream); + } + // Close the document and release resources + ldoc.Close(true); + } +} \ No newline at end of file diff --git a/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation/Set-value-from-PDF-annotation.csproj b/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation/Set-value-from-PDF-annotation.csproj new file mode 100644 index 00000000..2c04cbf0 --- /dev/null +++ b/Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation/Set-value-from-PDF-annotation.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Set_value_from_PDF_annotation + enable + enable + + + + + + +