إضافة تعليقات الأشكال باستخدام C#

تطبيق إدارة مستندات PDF يوفر أدوات متنوعة لتعليق المستندات. من منظور الهيكل الداخلي لـ PDF، هذه الأدوات هي تعليقات. نحن ندعم الأنواع التالية من أدوات الرسم.

  • تعليق خط - أداة لرسم الخطوط والسهام.
  • تعليق مربع - لرسم المربعات والمستطيلات.
  • تعليق دائرة - للدوائر والبيضاوات.
  • تعليق نص حر - لتعليق التعليق.
  • تعليق متعدد - للمتعددات والسحب.
  • تعليق بوليلاين - للخطوط المتصلة.

إضافة أشكال وأشكال على الصفحة

النهج لإضافة التعليق هو نمطي لأي منها.

تعمل مقتطفات الكود التالية أيضًا مع مكتبة Aspose.PDF.Drawing.

  1. تحميل ملف PDF أو إنشاء جديد بواسطة Document.
  2. إنشاء التعليق الجديد وتعيين المعلمات (مستطيل جديد، نقطة جديدة، عنوان، لون، عرض، إلخ).
  3. إنشاء PopupAnnotation جديد.
  4. ربط التعليق المنبثق بالتعليق الأصلي.
  5. إضافة التعليق إلى الصفحة.

إضافة خطوط أو سهام

الغرض من تعليق الخط هو عرض خط أو سهم بسيط على الصفحة. لإنشاء خط، نحتاج إلى كائن LineAnnotation جديد.
يأخذ مُنشئ فئة LineAnnotation أربعة معلمات:

  • الصفحة التي سيتم إضافة التعليق إليها.
  • المستطيل الذي يحدد حدود التعليق.
  • النقطتان اللتان تحددان بداية ونهاية الخط.

كما نحتاج إلى تهيئة بعض الخصائص:

  • Title - عادةً، هو اسم المستخدم الذي قام بعمل هذا التعليق.
  • Subject - يمكن أن تكون أي سلسلة، ولكن في الحالات الشائعة هو اسم التعليق.

لتنسيق خطنا، نحتاج إلى تعيين اللون، العرض، نمط البداية، ونمط النهاية. تتحكم هذه الخصائص في كيفية ظهور التعليق وسلوكه في عارض PDF. على سبيل المثال، تحدد خصائص StartingStyle و EndingStyle نوع الشكل الذي سيتم رسمه في نهايات الخط، مثل سهم مفتوح، سهم مغلق، دائرة، إلخ.

تظهر مقتطفات الكود التالية كيفية إضافة تعليق خط إلى ملف PDF:

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddLineAnnotation()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "Appartments.pdf"))
    {
        // Create Line Annotation
        var lineAnnotation = new Aspose.Pdf.Annotations.LineAnnotation(
            document.Pages[1],
            new Aspose.Pdf.Rectangle(550, 93, 562, 439),
            new Aspose.Pdf.Point(556, 99), new Aspose.Pdf.Point(556, 443))
        {
            Title = "John Smith",
            Color = Aspose.Pdf.Color.Red,
            Width = 3,
            StartingStyle = Aspose.Pdf.Annotations.LineEnding.OpenArrow,
            EndingStyle = Aspose.Pdf.Annotations.LineEnding.OpenArrow,
            Popup = new Aspose.Pdf.Annotations.PopupAnnotation(document.Pages[1], new Aspose.Pdf.Rectangle(842, 124, 1021, 266))
        };

        // Add annotation to the page
        document.Pages[1].Annotations.Add(lineAnnotation);

        // Save PDF document
        document.Save(dataDir + "AddLineAnnotation_out.pdf");
    }
}

إضافة مربع أو دائرة

ستعرض تعليقات Square و Circle مستطيلًا أو بيضاويًا على الصفحة. عند الفتح، ستعرض نافذة منبثقة تحتوي على نص الملاحظة المرتبطة. تشبه تعليقات المربعات تعليقات الدوائر (حالات من فئة Aspose. Pdf. Annotations. CircleAnnotation) باستثناء الشكل.

إضافة تعليق دائرة

لرسم تعليق دائرة أو بيضاوي جديد، نحتاج إلى إنشاء كائن CircleAnnotation جديد. يأخذ مُنشئ فئة CircleAnnotation معلمين:

  • الصفحة التي سيتم إضافة التعليق إليها.
  • المستطيل الذي يحدد حدود التعليق.

كما يمكننا تعيين بعض خصائص كائن CircleAnnotation، مثل العنوان، اللون، لون الداخل، الشفافية. تتحكم هذه الخصائص في كيفية ظهور التعليق وسلوكه في عارض PDF. هنا وفيما بعد في المربع، لون InteriorColor هو لون التعبئة و Color هو لون الحدود.

إضافة تعليق مربع

رسم مستطيل هو نفسه رسم دائرة. تظهر مقتطفات الكود التالية كيفية إضافة تعليقات الدائرة والمربع إلى صفحة PDF.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddCircleAndSquareAnnotations()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "appartments.pdf"))
    {
        // Create Circle Annotation
        var circleAnnotation = new Aspose.Pdf.Annotations.CircleAnnotation(document.Pages[1], new Aspose.Pdf.Rectangle(270, 160, 483, 383))
        {
            Title = "John Smith",
            Subject = "Circle",
            Color = Aspose.Pdf.Color.Red,
            InteriorColor = Aspose.Pdf.Color.MistyRose,
            Opacity = 0.5,
            Popup = new Aspose.Pdf.Annotations.PopupAnnotation(document.Pages[1], new Aspose.Pdf.Rectangle(842, 316, 1021, 459))
        };

        // Create Square Annotation
        var squareAnnotation = new Aspose.Pdf.Annotations.SquareAnnotation(document.Pages[1], new Aspose.Pdf.Rectangle(67, 317, 261, 459))
        {
            Title = "John Smith",
            Subject = "Rectangle",
            Color = Aspose.Pdf.Color.Blue,
            InteriorColor = Aspose.Pdf.Color.BlueViolet,
            Opacity = 0.25,
            Popup = new Aspose.Pdf.Annotations.PopupAnnotation(document.Pages[1], new Aspose.Pdf.Rectangle(842, 196, 1021, 338))
        };

        // Add annotations to the page
        document.Pages[1].Annotations.Add(circleAnnotation);
        document.Pages[1].Annotations.Add(squareAnnotation);

        // Save PDF document
        document.Save(dataDir + "AddCircleAndSquareAnnotations_out.pdf");
    }
}

كمثال، سنرى النتيجة التالية لإضافة تعليقات المربع والدائرة إلى مستند PDF:

إضافة تعليقات متعددة وبوليلاين

تتيح لك أداة Poly- إنشاء أشكال وحدود بعدد غير محدد من الجوانب على المستند.

تمثل تعليقات متعددة الأشكال على الصفحة. يمكن أن تحتوي على أي عدد من الرؤوس المتصلة بخطوط مستقيمة. تعليقات بوليلاين مشابهة أيضًا للمتعددات، الفرق الوحيد هو أن الرؤوس الأولى والأخيرة غير متصلة ضمنيًا.

إضافة تعليق متعدد

تكون PolygonAnnotation مسؤولة عن تعليقات الأشكال. يأخذ مُنشئ فئة PolygonAnnotation ثلاثة معلمات:

  • الصفحة التي سيتم إضافة التعليق إليها.
  • المستطيل الذي يحدد حدود التعليق.
  • مصفوفة النقاط التي تحدد رؤوس الشكل.

تستخدم Color و InteriorColor لألوان الحدود والتعبئة على التوالي.

إضافة تعليق بوليلاين

تكون PolygonAnnotation مسؤولة عن تعليقات الأشكال. يأخذ مُنشئ فئة PolygonAnnotation ثلاثة معلمات:

  • الصفحة التي سيتم إضافة التعليق إليها.
  • المستطيل الذي يحدد حدود التعليق.
  • مصفوفة النقاط التي تحدد رؤوس الشكل.

بدلاً من PolygonAnnotation، لا يمكننا ملء هذا الشكل، لذا لا نحتاج إلى استخدام InteriorColor.

تظهر مقتطفات الكود التالية كيفية إضافة تعليقات متعددة وبوليلاين إلى ملف PDF:

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddPolygonAndPolylineAnnotations()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "appartments.pdf"))
    {
        // Create Polygon Annotation
        var polygonAnnotation = new Aspose.Pdf.Annotations.PolygonAnnotation(
            document.Pages[1],
            new Aspose.Pdf.Rectangle(270, 193, 571, 383),
            new Aspose.Pdf.Point[] {
                new Aspose.Pdf.Point(274, 381),
                new Aspose.Pdf.Point(555, 381),
                new Aspose.Pdf.Point(555, 304),
                new Aspose.Pdf.Point(570, 304),
                new Aspose.Pdf.Point(570, 195),
                new Aspose.Pdf.Point(274, 195)
            })
        {
            Title = "John Smith",
            Color = Aspose.Pdf.Color.Blue,
            InteriorColor = Aspose.Pdf.Color.BlueViolet,
            Opacity = 0.25,
            Popup = new Aspose.Pdf.Annotations.PopupAnnotation(document.Pages[1], new Aspose.Pdf.Rectangle(842, 196, 1021, 338))
        };

        // Create Polyline Annotation
        var polylineAnnotation = new Aspose.Pdf.Annotations.PolylineAnnotation(
            document.Pages[1],
            new Aspose.Pdf.Rectangle(270, 193, 571, 383),
            new Aspose.Pdf.Point[] {
                new Aspose.Pdf.Point(545, 150),
                new Aspose.Pdf.Point(545, 190),
                new Aspose.Pdf.Point(667, 190),
                new Aspose.Pdf.Point(667, 110),
                new Aspose.Pdf.Point(626, 111)
            })
        {
            Title = "John Smith",
            Color = Aspose.Pdf.Color.Red,
            Popup = new Aspose.Pdf.Annotations.PopupAnnotation(document.Pages[1], new Aspose.Pdf.Rectangle(842, 196, 1021, 338))
        };

        // Add annotations to the page
        document.Pages[1].Annotations.Add(polygonAnnotation);
        document.Pages[1].Annotations.Add(polylineAnnotation);

        // Save PDF document
        document.Save(dataDir + "AddPolygonAndPolylineAnnotations_out.pdf");
    }
}

الحصول على الأشكال

تُخزن جميع التعليقات في مجموعة Annotations. يمكن لأي تعليق تقديم نوعه من خلال خاصية AnnotationType. لذلك، يمكننا إجراء استعلام LINQ لتصفية التعليقات المطلوبة.

الحصول على تعليقات الخط

توضح المثال أدناه كيفية الحصول على جميع تعليقات الخط من الصفحة الأولى من مستند PDF.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ReadLineAnnotations()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "Appartments_mod.pdf"))
    {
        // Get all line annotations from the first page
        var lineAnnotations = document.Pages[1].Annotations
            .Where(a => a.AnnotationType == Aspose.Pdf.Annotations.AnnotationType.Line)
            .Cast<Aspose.Pdf.Annotations.LineAnnotation>();

        // Iterate through each line annotation and print its coordinates
        foreach (var la in lineAnnotations)
        {
            Console.WriteLine($"[{la.Starting.X},{la.Starting.Y}]-[{la.Ending.X},{la.Ending.Y}]");
        }
    }
}

الحصول على تعليقات الدائرة

توضح المثال أدناه كيفية الحصول على جميع تعليقات بوليلاين من الصفحة الأولى من مستند PDF.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ReadCircleAnnotations()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "Appartments_mod.pdf"))
    {
        // Get all circle annotations from the first page
        var circleAnnotations = document.Pages[1].Annotations
            .Where(a => a.AnnotationType == Aspose.Pdf.Annotations.AnnotationType.Circle)
            .Cast<Aspose.Pdf.Annotations.CircleAnnotation>();

        // Iterate through each circle annotation and print its rectangle
        foreach (var ca in circleAnnotations)
        {
            Console.WriteLine($"[{ca.Rect}]");
        }
    }
}

الحصول على تعليقات المربع

توضح المثال أدناه كيفية الحصول على جميع تعليقات بوليلاين من الصفحة الأولى من مستند PDF.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ReadSquareAnnotations()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "Appartments_mod.pdf"))
    {
        // Get all square annotations from the first page
        var squareAnnotations = document.Pages[1].Annotations
            .Where(a => a.AnnotationType == Aspose.Pdf.Annotations.AnnotationType.Square)
            .Cast<Aspose.Pdf.Annotations.SquareAnnotation>();

        // Iterate through each square annotation and print its rectangle
        foreach (var sq in squareAnnotations)
        {
            Console.WriteLine($"[{sq.Rect}]");
        }
    }
}

الحصول على تعليقات بوليلاين

توضح المثال أدناه كيفية الحصول على جميع تعليقات بوليلاين من الصفحة الأولى من مستند PDF.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ReadPolylineAnnotations()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "Appartments_mod.pdf"))
    {
        // Get all polyline annotations from the first page
        var polyAnnotations = document.Pages[1].Annotations
            .Where(a => a.AnnotationType == Aspose.Pdf.Annotations.AnnotationType.PolyLine)
            .Cast<Aspose.Pdf.Annotations.PolylineAnnotation>();

        // Iterate through each polyline annotation and print its rectangle
        foreach (var pa in polyAnnotations)
        {
            Console.WriteLine($"[{pa.Rect}]");
        }
    }
}

الحصول على تعليقات متعددة

توضح المثال أدناه كيفية الحصول على جميع تعليقات متعددة من الصفحة الأولى من مستند PDF.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ReadPolygonAnnotations()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "Appartments_mod.pdf"))
    {
        // Get all polygon annotations from the first page
        var polyAnnotations = document.Pages[1].Annotations
            .Where(a => a.AnnotationType == Aspose.Pdf.Annotations.AnnotationType.Polygon)
            .Cast<Aspose.Pdf.Annotations.PolygonAnnotation>();

        // Iterate through each polygon annotation and print its rectangle
        foreach (var pa in polyAnnotations)
        {
            Console.WriteLine($"[{pa.Rect}]");
        }
    }
}

حذف الأشكال

النهج لإزالة التعليق من PDF بسيط جدًا:

  • اختر التعليقات المراد حذفها (قم بإنشاء مجموعة).
  • قم بالتكرار على المجموعة باستخدام حلقة foreach، واحذف كل تعليق من مجموعة التعليقات باستخدام طريقة الحذف.

حذف تعليق الخط

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void DeleteLineAnnotations()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "Appartments_mod.pdf"))
    {
        // Get all line annotations from the first page
        var lineAnnotations = document.Pages[1].Annotations
            .Where(a => a.AnnotationType == Aspose.Pdf.Annotations.AnnotationType.Line)
            .Cast<Aspose.Pdf.Annotations.LineAnnotation>();

        // Iterate through each line annotation and delete it
        foreach (var la in lineAnnotations)
        {
            document.Pages[1].Annotations.Delete(la);
        }

        // Save PDF document
        document.Save(dataDir + "DeleteLineAnnotations_out.pdf");
    }
}

حذف تعليقات الدائرة والمربع

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void DeleteCircleAndSquareAnnotations()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "Appartments_mod.pdf"))
    {
        // Get all circle and square annotations from the first page
        var figures = document.Pages[1].Annotations
            .Where(a =>
                a.AnnotationType == Aspose.Pdf.Annotations.AnnotationType.Circle
                || a.AnnotationType == Aspose.Pdf.Annotations.AnnotationType.Square);

        // Iterate through each figure annotation and delete it
        foreach (var fig in figures)
        {
            document.Pages[1].Annotations.Delete(fig);
        }

        // Save PDF document
        document.Save(dataDir + "DeleteCircleAndSquareAnnotations_out.pdf");
    }
}

حذف تعليقات متعددة وبوليلاين

تظهر مقتطفات الكود التالية كيفية حذف تعليقات متعددة وبوليلاين من ملف PDF.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void DeletePolylineAndPolygonAnnotations()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "Appartments_mod.pdf"))
    {
        // Get all polyline and polygon annotations from the first page
        var polyAnnotations = document.Pages[1].Annotations
            .Where(a => a.AnnotationType == Aspose.Pdf.Annotations.AnnotationType.PolyLine
                        || a.AnnotationType == Aspose.Pdf.Annotations.AnnotationType.Polygon);

        // Iterate through each polyline or polygon annotation and delete it
        foreach (var pa in polyAnnotations)
        {
            document.Pages[1].Annotations.Delete(pa);
        }

        // Save PDF document
        document.Save(dataDir + DeletePolylineAndPolygonAnnotations_out.pdf");
    }
}

كيفية إضافة تعليق حبر إلى ملف PDF

يمثل تعليق الحبر “خربشة” حرة تتكون من مسار واحد أو أكثر غير متصل. عند الفتح، ستظهر نافذة منبثقة تحتوي على نص الملاحظة المرتبطة.

يمثل InkAnnotation خربشة حرة تتكون من نقطة واحدة أو أكثر غير متصلة. يرجى تجربة استخدام مقتطف الكود التالي لإضافة InkAnnotation في مستند PDF.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddInkAnnotation()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "appartments.pdf"))
    {
        // Get first page
        var page = document.Pages[1];

        // Define the rectangle for the ink annotation
        var arect = new Aspose.Pdf.Rectangle(156.574, 521.316, 541.168, 575.703);

        // Create a list of ink paths
        IList<Aspose.Pdf.Point[]> inkList = new List<Aspose.Pdf.Point[]>();
        var arrpt = new[]
        {
            new Aspose.Pdf.Point(209.727, 542.263),
            new Aspose.Pdf.Point(209.727, 541.94),
            new Aspose.Pdf.Point(209.727, 541.616)
        };
        inkList.Add(arrpt);

        // Create the ink annotation
        var ia = new Aspose.Pdf.Annotations.InkAnnotation(page, arect, inkList)
        {
            Title = "John Smith",
            Subject = "Pencil",
            Color = Aspose.Pdf.Color.LightBlue,
            CapStyle = Aspose.Pdf.Annotations.CapStyle.Rounded,
            Opacity = 0.5
        };

        // Set the border for the annotation
        var border = new Aspose.Pdf.Annotations.Border(ia)
        {
            Width = 25
        };
        ia.Border = border;

        // Add the annotation to the page
        page.Annotations.Add(ia);

        // Save PDF document
        document.Save(dataDir + "AddInkAnnotation_out.pdf");
    }
}

تعيين عرض خط InkAnnotation

يمكن تغيير عرض InkAnnottion باستخدام كائنات LineInfo و Border.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddInkAnnotationWithLineWidth()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

    // Create PDF document
    using (var document = new Aspose.Pdf.Document())
    {
        // Add page
        var page = document.Pages.Add();

        // Create a list of ink paths
        IList<Aspose.Pdf.Point[]> inkList = new List<Aspose.Pdf.Point[]>();

        // Define line information
        var lineInfo = new Aspose.Pdf.Facades.LineInfo
        {
            VerticeCoordinate = new float[] { 55, 55, 70, 70, 70, 90, 150, 60 },
            Visibility = true,
            LineColor = System.Drawing.Color.Red,
            LineWidth = 2
        };

        // Convert line coordinates to Aspose.Pdf.Point array
        int length = lineInfo.VerticeCoordinate.Length / 2;
        var gesture = new Aspose.Pdf.Point[length];
        for (int i = 0; i < length; i++)
        {
            gesture[i] = new Aspose.Pdf.Point(lineInfo.VerticeCoordinate[2 * i], lineInfo.VerticeCoordinate[2 * i + 1]);
        }

        // Add the gesture to the ink list
        inkList.Add(gesture);

        // Create the ink annotation
        var a1 = new Aspose.Pdf.Annotations.InkAnnotation(document.Pages[1], new Aspose.Pdf.Rectangle(100, 100, 300, 300), inkList)
        {
            Subject = "Test",
            Title = "Title",
            Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green)
        };

        // Set the border for the annotation
        var border = new Aspose.Pdf.Annotations.Border(a1)
        {
            Width = 3,
            Effect = Aspose.Pdf.Annotations.BorderEffect.Cloudy,
            Dash = new Aspose.Pdf.Annotations.Dash(1, 1),
            Style = Aspose.Pdf.Annotations.BorderStyle.Solid
        };
        a1.Border = border;

        // Add the annotation to the page
        page.Annotations.Add(a1);

        // Save PDF document
        document.Save(dataDir + "lnkAnnotationLineWidth_out.pdf");
    }
}

حذف تعليق الدائرة

تظهر مقتطفات الكود التالية كيفية حذف تعليق الدائرة من ملف PDF.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void DeleteCircleAnnotation()
{
	// The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();
	
    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "Appartments_mod.pdf"))
    {
        var circleAnnotations = document.Pages[1].Annotations
            .Where(a => a.AnnotationType == AnnotationType.Circle)
            .Cast<Aspose.Pdf.Annotations.CircleAnnotation>();

        foreach (var ca in circleAnnotations)
        {
            document.Pages[1].Annotations.Delete(ca);
        }

        // Save PDF document
        document.Save(dataDir + "DeleteCircleAnnotation_out.pdf");
    }
}