-
Notifications
You must be signed in to change notification settings - Fork 47
952337 Added Get and Set values for PDF annotation sample code #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation.sln
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 added
BIN
+30.5 KB
Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation/Data/Input.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
...om-PDF-annotation/.NET/Get-value-from-PDF-annotation/Get-value-from-PDF-annotation.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
40 changes: 40 additions & 0 deletions
40
Annotation/Get-value-from-PDF-annotation/.NET/Get-value-from-PDF-annotation/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| 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)) | ||
| { | ||
| using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputStream)) | ||
| { | ||
| // Get the first page | ||
| PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; | ||
|
|
||
| // Get all annotations on the page | ||
| PdfLoadedAnnotationCollection annotations = loadedPage.Annotations; | ||
|
|
||
| // Make sure the 65th annotation exists and is a circle annotation | ||
| if (annotations.Count > 64 && annotations[64] is PdfLoadedCircleAnnotation circleAnnotation) | ||
| { | ||
| // Get the review history from the circle annotation | ||
| PdfLoadedPopupAnnotationCollection reviewHistory = circleAnnotation.ReviewHistory; | ||
|
|
||
| // Ensure review history has at least two items | ||
| if (reviewHistory != null && reviewHistory.Count > 1) | ||
| { | ||
| // Get the second popup annotation from review history | ||
| PdfLoadedPopupAnnotation popupAnnotation = reviewHistory[1] as PdfLoadedPopupAnnotation; | ||
|
|
||
| if (popupAnnotation != null) | ||
| { | ||
| // Get values for the "State" key | ||
| List<string> values = popupAnnotation.GetValues("State"); | ||
| foreach (string value in values) | ||
| { | ||
| Console.WriteLine(value); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation.sln
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 added
BIN
+30.5 KB
Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation/Data/Input.pdf
Binary file not shown.
Empty file.
49 changes: 49 additions & 0 deletions
49
Annotation/Set-value-from-PDF-annotation/.NET/Set-value-from-PDF-annotation/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| | ||
| 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)) | ||
| { | ||
| using (PdfLoadedDocument ldoc = new PdfLoadedDocument(inputStream)) | ||
| { | ||
| // Get the first page | ||
| PdfLoadedPage lpage = ldoc.Pages[0] as PdfLoadedPage; | ||
|
|
||
| // Get all annotations on the page | ||
| PdfLoadedAnnotationCollection annots = lpage.Annotations; | ||
|
|
||
| // Access the 65th annotation (index starts at 0) | ||
| if (annots.Count > 64 && annots[64] is PdfLoadedCircleAnnotation Icircle) | ||
| { | ||
| // Get the author of the circle annotation | ||
| string author = Icircle.Author; | ||
|
|
||
| // Get the review history and comments | ||
| PdfLoadedPopupAnnotationCollection collection = Icircle.ReviewHistory; | ||
| PdfLoadedPopupAnnotationCollection collectionComments = Icircle.Comments; | ||
|
|
||
| // Check if there's at least a second item in the review history | ||
| if (collection != null && collection.Count > 1) | ||
| { | ||
| PdfLoadedPopupAnnotation annotation = collection[1] as PdfLoadedPopupAnnotation; | ||
|
|
||
| if (annotation != null) | ||
| { | ||
| // Set custom state and state model | ||
| annotation.SetValues("State", "Unknown"); | ||
| annotation.SetValues("StateModel", "CustomState"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Save the modified document using FileStream | ||
| using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.Write)) | ||
| { | ||
| ldoc.Save(outputStream); | ||
| } | ||
|
|
||
| ldoc.Close(true); | ||
| } | ||
| } | ||
15 changes: 15 additions & 0 deletions
15
...om-PDF-annotation/.NET/Set-value-from-PDF-annotation/Set-value-from-PDF-annotation.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.