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,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
Binary file not shown.
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>Get_value_from_PDF_annotation</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

</Project>
Original file line number Diff line number Diff line change
@@ -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<string> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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);
}
}
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>Set_value_from_PDF_annotation</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

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

</Project>
Loading