diff --git a/Annotation/Getting-annotation-creation-date-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf.sln b/Annotation/Getting-annotation-creation-date-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf.sln new file mode 100644 index 00000000..58bf25fd --- /dev/null +++ b/Annotation/Getting-annotation-creation-date-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf.sln @@ -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 diff --git a/Annotation/Getting-annotation-creation-date-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf/Data/Input.pdf b/Annotation/Getting-annotation-creation-date-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf/Data/Input.pdf new file mode 100644 index 00000000..d98d79ad Binary files /dev/null and b/Annotation/Getting-annotation-creation-date-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf/Data/Input.pdf differ diff --git a/Annotation/Getting-annotation-creation-date-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf/Getting-annotation-creation-date-from-existing-pdf.csproj b/Annotation/Getting-annotation-creation-date-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf/Getting-annotation-creation-date-from-existing-pdf.csproj new file mode 100644 index 00000000..a0a3748e --- /dev/null +++ b/Annotation/Getting-annotation-creation-date-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf/Getting-annotation-creation-date-from-existing-pdf.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Getting_annotation_creation_date_from_existing_pdf + enable + enable + + + + + + + diff --git a/Annotation/Getting-annotation-creation-date-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf/Program.cs b/Annotation/Getting-annotation-creation-date-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf/Program.cs new file mode 100644 index 00000000..7338c81b --- /dev/null +++ b/Annotation/Getting-annotation-creation-date-from-existing-pdf/.NET/Getting-annotation-creation-date-from-existing-pdf/Program.cs @@ -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; + } + } +} diff --git a/Annotation/Getting-annotation-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF.sln b/Annotation/Getting-annotation-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF.sln new file mode 100644 index 00000000..5753f77e --- /dev/null +++ b/Annotation/Getting-annotation-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF.sln @@ -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 diff --git a/Annotation/Getting-annotation-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF/Data/Input.pdf b/Annotation/Getting-annotation-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF/Data/Input.pdf new file mode 100644 index 00000000..50d4c34b Binary files /dev/null and b/Annotation/Getting-annotation-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF/Data/Input.pdf differ diff --git a/Annotation/Getting-annotation-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF/Getting-annotation-type-from-existing-PDF.csproj b/Annotation/Getting-annotation-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF/Getting-annotation-type-from-existing-PDF.csproj new file mode 100644 index 00000000..1043569a --- /dev/null +++ b/Annotation/Getting-annotation-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF/Getting-annotation-type-from-existing-PDF.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Getting_annotation_type_from_existing_PDF + enable + enable + + + + + + + diff --git a/Annotation/Getting-annotation-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF/Program.cs b/Annotation/Getting-annotation-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF/Program.cs new file mode 100644 index 00000000..69731fa4 --- /dev/null +++ b/Annotation/Getting-annotation-type-from-existing-PDF/.NET/Getting-annotation-type-from-existing-PDF/Program.cs @@ -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; + } +} \ No newline at end of file