Tambahkan Anotasi Gambar menggunakan C#

Aplikasi manajemen dokumen PDF menyediakan berbagai alat untuk memberi anotasi pada dokumen. Dari perspektif struktur internal PDF, alat ini adalah anotasi. Kami mendukung jenis alat gambar berikut.

  • Anotasi Garis - alat untuk menggambar garis dan panah.
  • Anotasi Persegi - untuk menggambar persegi dan persegi panjang.
  • Anotasi Lingkaran - untuk oval dan lingkaran.
  • Anotasi Teks Bebas - untuk komentar Callout.
  • Anotasi Poligon - untuk poligon dan awan.
  • Anotasi Polilin - untuk Garis Terhubung.

Menambahkan Bentuk dan Gambar di Halaman

Pendekatan untuk menambahkan anotasi adalah tipikal untuk salah satu dari mereka.

Potongan kode berikut juga bekerja dengan Aspose.PDF.Drawing pustaka.

  1. Muat file PDF atau buat baru dengan Document.
  2. Buat anotasi baru dan atur parameter (Rectangle baru, Point baru, judul, warna, lebar, dll).
  3. Buat PopupAnnotation baru.
  4. Tautkan anotasi Popup dengan yang asli.
  5. Tambahkan anotasi ke halaman

Menambahkan Garis atau Panah

Tujuan dari anotasi garis adalah untuk menampilkan garis atau panah yang sederhana di halaman. Untuk membuat Garis, kita perlu objek LineAnnotation baru.
Konstruktor kelas LineAnnotation mengambil empat parameter:

  • Halaman tempat anotasi akan ditambahkan.
  • Persegi panjang yang mendefinisikan batas anotasi.
  • Dua titik yang mendefinisikan awal dan akhir garis.

Juga kita perlu menginisialisasi beberapa properti:

  • Title - biasanya, ini adalah nama pengguna yang membuat komentar ini.
  • Subject - bisa berupa string apa pun, tetapi dalam kasus umum ini adalah nama anotasi.

Untuk menata garis kita perlu mengatur warna, lebar, gaya awal, dan gaya akhir. Properti ini mengontrol bagaimana anotasi akan terlihat dan berperilaku di penampil PDF. Misalnya, properti StartingStyle dan EndingStyle menentukan jenis bentuk apa yang akan digambar di ujung garis, seperti panah terbuka, panah tertutup, lingkaran, dll.

Potongan kode berikut menunjukkan cara menambahkan Anotasi Garis ke file 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");
    }
}

Menambahkan Persegi atau Lingkaran

Anotasi Persegi dan Lingkaran akan menampilkan persegi panjang atau elips di halaman. Ketika dibuka, mereka akan menampilkan jendela pop-up yang berisi teks dari catatan terkait. Anotasi persegi mirip dengan anotasi lingkaran (instansi dari kelas Aspose. Pdf. Annotations. CircleAnnotation) kecuali bentuknya.

Menambahkan anotasi Lingkaran

Untuk menggambar anotasi lingkaran atau elips baru, kita perlu membuat objek CircleAnnotation baru. Konstruktor kelas CircleAnnotation mengambil dua parameter:

  • Halaman tempat anotasi akan ditambahkan.
  • Persegi panjang yang mendefinisikan batas anotasi.

Juga kita dapat mengatur beberapa properti dari objek CircleAnnotation, seperti judul, warna, warna interior, opasitas. Properti ini mengontrol bagaimana anotasi akan terlihat dan berperilaku di penampil PDF. Di sini dan selanjutnya di Persegi, warna InteriorColor adalah warna isi dan Color adalah warna batas.

Menambahkan anotasi Persegi

Menggambar persegi panjang sama dengan menggambar lingkaran. Potongan kode berikut menunjukkan cara menambahkan anotasi lingkaran dan persegi ke halaman 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");
    }
}

Sebagai contoh, kita akan melihat hasil berikut dari menambahkan anotasi Persegi dan Lingkaran ke dokumen PDF:

Menambahkan Anotasi Poligon dan Polilin

Alat Poly- memungkinkan Anda untuk membuat bentuk dan garis besar dengan jumlah sisi yang sembarang di dokumen.

Anotasi Poligon mewakili poligon di halaman. Mereka dapat memiliki jumlah titik sudut yang terhubung oleh garis lurus. Anotasi Polilin juga mirip dengan poligon, satu-satunya perbedaan adalah bahwa titik sudut pertama dan terakhir tidak terhubung secara implisit.

Menambahkan Anotasi Poligon

PolygonAnnotation bertanggung jawab untuk anotasi poligon. Konstruktor kelas PolygonAnnotation mengambil tiga parameter:

  • Halaman tempat anotasi akan ditambahkan.
  • Persegi panjang yang mendefinisikan batas anotasi.
  • Array titik yang mendefinisikan titik sudut poligon.

Color dan InteriorColor digunakan untuk warna batas dan warna isi masing-masing.

Menambahkan Anotasi Polilin

PolygonAnnotation bertanggung jawab untuk anotasi poligon. Konstruktor kelas PolygonAnnotation mengambil tiga parameter:

  • Halaman tempat anotasi akan ditambahkan.
  • Persegi panjang yang mendefinisikan batas anotasi.
  • Array titik yang mendefinisikan titik sudut poligon.

Sebagai pengganti PolygonAnnotation, kita tidak dapat mengisi bentuk ini, jadi kita tidak perlu menggunakan InteriorColor.

Potongan kode berikut menunjukkan cara menambahkan Anotasi Poligon dan Polilin ke file 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");
    }
}

Mendapatkan Gambar

Semua anotasi disimpan dalam koleksi Annotations. Setiap anotasi dapat memperkenalkan jenisnya melalui properti AnnotationType. Oleh karena itu, kita dapat membuat kueri LINQ untuk memfilter anotasi yang diinginkan.

Mendapatkan Anotasi Garis

Contoh di bawah ini menjelaskan cara mendapatkan semua Anotasi Garis dari halaman pertama dokumen 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}]");
        }
    }
}

Mendapatkan Anotasi Lingkaran

Contoh di bawah ini menjelaskan cara mendapatkan semua Anotasi Polilin dari halaman pertama dokumen 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}]");
        }
    }
}

Mendapatkan Anotasi Persegi

Contoh di bawah ini menjelaskan cara mendapatkan semua Anotasi Polilin dari halaman pertama dokumen 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}]");
        }
    }
}

Mendapatkan Anotasi Polilin

Contoh di bawah ini menjelaskan cara mendapatkan semua Anotasi Polilin dari halaman pertama dokumen 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}]");
        }
    }
}

Mendapatkan Anotasi Poligon

Contoh di bawah ini menjelaskan cara mendapatkan semua Anotasi Poligon dari halaman pertama dokumen 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}]");
        }
    }
}

Menghapus Gambar

Pendekatan untuk menghapus anotasi dari PDF cukup sederhana:

  • Pilih anotasi untuk dihapus (buat beberapa koleksi).
  • Iterasi melalui koleksi menggunakan loop foreach, dan hapus setiap anotasi dari koleksi anotasi menggunakan metode Delete.

Menghapus Anotasi Garis

// 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");
    }
}

Menghapus Anotasi Lingkaran dan Persegi

// 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");
    }
}

Menghapus Anotasi Poligon dan Polilin

Potongan kode berikut menunjukkan cara Menghapus Anotasi Poligon dan Polilin dari file 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");
    }
}

Cara menambahkan Anotasi Tinta ke file PDF

Anotasi Tinta mewakili “coretan” bebas tangan yang terdiri dari satu atau lebih jalur yang terputus. Ketika dibuka, ia akan menampilkan jendela pop-up yang berisi teks dari catatan terkait.

InkAnnotation mewakili coretan bebas tangan yang terdiri dari satu atau lebih titik yang terputus. Silakan coba menggunakan potongan kode berikut untuk menambahkan InkAnnotation dalam dokumen 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");
    }
}

Atur Lebar Garis InkAnnotation

Lebar dari InkAnnottion dapat diubah menggunakan objek LineInfo dan 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");
    }
}

Menghapus Anotasi Lingkaran

Potongan kode berikut menunjukkan cara Menghapus Anotasi Lingkaran dari file 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");
    }
}