-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
203156 Updated UG to get annotation type and creation date from loade…
…d annotation
- Loading branch information
1 parent
15776f1
commit 76a9746
Showing
8 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...eation-date-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf.sln
This file contains 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.35527.113 d17.12 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Getting-annotation-creation-date-from-existing-pdf", "Getting-annotation-creation-date-from-existing-pdf\Getting-annotation-creation-date-from-existing-pdf.csproj", "{99C4DAFC-5512-4A2B-AAE0-9CF0464BBD1C}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{99C4DAFC-5512-4A2B-AAE0-9CF0464BBD1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{99C4DAFC-5512-4A2B-AAE0-9CF0464BBD1C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{99C4DAFC-5512-4A2B-AAE0-9CF0464BBD1C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{99C4DAFC-5512-4A2B-AAE0-9CF0464BBD1C}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+98.7 KB
...-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf/Data/Input.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
...creation-date-from-existing-pdf/Getting-annotation-creation-date-from-existing-pdf.csproj
This file contains 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>Getting_annotation_creation_date_from_existing_pdf</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" /> | ||
</ItemGroup> | ||
|
||
</Project> |
90 changes: 90 additions & 0 deletions
90
...date-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf/Program.cs
This file contains 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,90 @@ | ||
using Syncfusion.Pdf.Interactive; | ||
using Syncfusion.Pdf.Parsing; | ||
using Syncfusion.Pdf; | ||
|
||
// Load the PDF document | ||
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read); | ||
PdfLoadedDocument document = new PdfLoadedDocument(inputStream); | ||
// Load the collection of pages in the PDF document | ||
PdfLoadedPageCollection loadedPages = document.Pages; | ||
|
||
// Iterate through all the pages in the document | ||
for (int i = 0; i < loadedPages.Count; i++) | ||
{ | ||
// Access the current page | ||
PdfLoadedPage loadedPage = loadedPages[i] as PdfLoadedPage; | ||
// Access the annotation collection on the current page | ||
PdfLoadedAnnotationCollection annotations = loadedPage.Annotations; | ||
// Get the total number of annotations on the current page | ||
int numAnnotations = annotations.Count; | ||
// Iterate through all annotations on the current page | ||
for (int j = 0; j < numAnnotations; j++) | ||
{ | ||
// Identify the type of the annotation and process accordingly | ||
switch (annotations[j].GetType().ToString()) | ||
{ | ||
case "Syncfusion.Pdf.Interactive.PdfLoadedFreeTextAnnotation": | ||
// Handle FreeText annotation | ||
PdfLoadedFreeTextAnnotation freeTextAnnot = annotations[j] as PdfLoadedFreeTextAnnotation; | ||
DateTime creationDate0 = freeTextAnnot.CreationDate; | ||
Console.WriteLine(creationDate0); | ||
break; | ||
|
||
case "Syncfusion.Pdf.Interactive.PdfLoadedEllipseAnnotation": | ||
// Handle Ellipse annotation | ||
PdfLoadedEllipseAnnotation ellipseAnnot = annotations[j] as PdfLoadedEllipseAnnotation; | ||
DateTime creationDate1 = ellipseAnnot.CreationDate; | ||
Console.WriteLine(creationDate1); | ||
break; | ||
|
||
case "Syncfusion.Pdf.Interactive.PdfLoadedRectangleAnnotation": | ||
// Handle Rectangle annotation | ||
PdfLoadedRectangleAnnotation rectangleAnnot = annotations[j] as PdfLoadedRectangleAnnotation; | ||
DateTime creationDate2 = rectangleAnnot.CreationDate; | ||
Console.WriteLine(creationDate2); | ||
break; | ||
|
||
case "Syncfusion.Pdf.Interactive.PdfLoadedSquareAnnotation": | ||
// Handle Square annotation | ||
PdfLoadedSquareAnnotation squareAnnot = annotations[j] as PdfLoadedSquareAnnotation; | ||
DateTime creationDate3 = squareAnnot.CreationDate; | ||
Console.WriteLine(creationDate3); | ||
break; | ||
|
||
case "Syncfusion.Pdf.Interactive.PdfLoadedAnnotation": | ||
// Handle Circle annotation | ||
PdfLoadedCircleAnnotation circleAnnot = annotations[j] as PdfLoadedCircleAnnotation; | ||
DateTime creationDate4 = circleAnnot.CreationDate; | ||
Console.WriteLine(creationDate4); | ||
break; | ||
|
||
case "Syncfusion.Pdf.Interactive.PdfLoadedLineAnnotation": | ||
// Handle Line annotation | ||
PdfLoadedLineAnnotation lineAnnot = annotations[j] as PdfLoadedLineAnnotation; | ||
DateTime creationDate5 = lineAnnot.CreationDate; | ||
Console.WriteLine(creationDate5); | ||
break; | ||
|
||
case "Syncfusion.Pdf.Interactive.PdfLoadedInkAnnotation": | ||
// Handle Ink annotation | ||
PdfLoadedInkAnnotation inkAnnot = annotations[j] as PdfLoadedInkAnnotation; | ||
DateTime creationDate6 = inkAnnot.CreationDate; | ||
Console.WriteLine(creationDate6); | ||
break; | ||
|
||
case "Syncfusion.Pdf.Interactive.PdfLoadedRubberStampAnnotation": | ||
// Handle Rubber Stamp annotation | ||
PdfLoadedRubberStampAnnotation stampAnnot = annotations[j] as PdfLoadedRubberStampAnnotation; | ||
DateTime creationDate7 = stampAnnot.CreationDate; | ||
Console.WriteLine(creationDate7); | ||
break; | ||
|
||
case "Syncfusion.Pdf.Interactive.PdfLoadedTextMarkupAnnotation": | ||
// Handle Text Markup annotation | ||
PdfLoadedTextMarkupAnnotation textAnnot = annotations[j] as PdfLoadedTextMarkupAnnotation; | ||
DateTime creationDate8 = textAnnot.CreationDate; | ||
Console.WriteLine(creationDate8); | ||
break; | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ting-annotation-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF.sln
This file contains 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.35527.113 d17.12 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Getting-annotation-type-from-existing-PDF", "Getting-annotation-type-from-existing-PDF\Getting-annotation-type-from-existing-PDF.csproj", "{8985CAE2-2683-4690-BFA7-3A2A16065CBD}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{8985CAE2-2683-4690-BFA7-3A2A16065CBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8985CAE2-2683-4690-BFA7-3A2A16065CBD}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8985CAE2-2683-4690-BFA7-3A2A16065CBD}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8985CAE2-2683-4690-BFA7-3A2A16065CBD}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+98.8 KB
...tion-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF/Data/Input.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
...etting-annotation-type-from-existing-PDF/Getting-annotation-type-from-existing-PDF.csproj
This file contains 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>Getting_annotation_type_from_existing_PDF</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" /> | ||
</ItemGroup> | ||
|
||
</Project> |
59 changes: 59 additions & 0 deletions
59
...notation-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF/Program.cs
This file contains 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,59 @@ | ||
using Syncfusion.Pdf.Interactive; | ||
using Syncfusion.Pdf.Parsing; | ||
using Syncfusion.Pdf; | ||
|
||
//Load the PDF document using a file stream | ||
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read); | ||
PdfLoadedDocument document = new PdfLoadedDocument(inputStream); | ||
// Load the page collection from the PDF document | ||
PdfLoadedPageCollection loadedPages = document.Pages; | ||
|
||
// Iterate through all pages in the document | ||
for (int i = 0; i < loadedPages.Count; i++) | ||
{ | ||
// Access each page | ||
PdfLoadedPage loadedPage = loadedPages[i] as PdfLoadedPage; | ||
|
||
// Check if the page contains annotations | ||
if (loadedPage.Annotations.Count > 0) | ||
{ | ||
// Iterate through each annotation on the page | ||
foreach (PdfLoadedAnnotation annot in loadedPage.Annotations) | ||
{ | ||
// Identify the type of the annotation | ||
PdfLoadedAnnotationType annotationType = FindType(annot); | ||
|
||
// Print the annotation type to the console | ||
Console.WriteLine(annotationType); | ||
} | ||
} | ||
} | ||
// Close the document and release resources | ||
document.Close(true); | ||
inputStream.Dispose(); | ||
Console.ReadKey(); | ||
|
||
// Method to find the type of a given annotation | ||
static PdfLoadedAnnotationType FindType(PdfLoadedAnnotation annotation) | ||
{ | ||
if (annotation is PdfLoadedRectangleAnnotation) | ||
{ | ||
return PdfLoadedAnnotationType.RectangleAnnotation; | ||
} | ||
else if (annotation is PdfLoadedTextMarkupAnnotation) | ||
{ | ||
return PdfLoadedAnnotationType.TextMarkupAnnotation; | ||
} | ||
else if (annotation is PdfLoadedTextWebLinkAnnotation) | ||
{ | ||
return PdfLoadedAnnotationType.TextWebLinkAnnotation; | ||
} | ||
else if (annotation is PdfLoadedPopupAnnotation) | ||
{ | ||
return PdfLoadedAnnotationType.PopupAnnotation; | ||
} | ||
else | ||
{ | ||
return PdfLoadedAnnotationType.Null; | ||
} | ||
} |