Skip to content

Commit

Permalink
203156 Resolved the gvien feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
sameerkhan001 committed Dec 24, 2024
1 parent 76a9746 commit ff9269c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,71 +20,16 @@
// 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())
// Iterate through rectangle annotations
if (annotations[j].GetType().ToString() == "Syncfusion.Pdf.Interactive.PdfLoadedRectangleAnnotation")
{
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;
// Handle rectangle annotation
PdfLoadedRectangleAnnotation rectangleAnnot = annotations[j] as PdfLoadedRectangleAnnotation;
DateTime creationDate = rectangleAnnot.CreationDate;
Console.WriteLine(creationDate);
}
}
}
//Close the document
document.Close(true);
inputStream.Dispose();
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
using Syncfusion.Pdf.Parsing;
using Syncfusion.Pdf;

//Load the PDF document using a file stream
// 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;

Expand All @@ -21,39 +22,36 @@
foreach (PdfLoadedAnnotation annot in loadedPage.Annotations)
{
// Identify the type of the annotation
PdfLoadedAnnotationType annotationType = FindType(annot);
PdfLoadedAnnotationType annotationType;

if (annot is PdfLoadedRectangleAnnotation)
{
annotationType = PdfLoadedAnnotationType.RectangleAnnotation;
}
else if (annot is PdfLoadedTextMarkupAnnotation)
{
annotationType = PdfLoadedAnnotationType.TextMarkupAnnotation;
}
else if (annot is PdfLoadedTextWebLinkAnnotation)
{
annotationType = PdfLoadedAnnotationType.TextWebLinkAnnotation;
}
else if (annot is PdfLoadedPopupAnnotation)
{
annotationType = PdfLoadedAnnotationType.PopupAnnotation;
}
else
{
annotationType = PdfLoadedAnnotationType.Null;
}

// 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;
}
}
Console.ReadKey();

0 comments on commit ff9269c

Please sign in to comment.