How To Add Ink Annotation To PDF Documents Using PDF Mosaic .NET

This sample shows how to add inkt annotations to your PDF document.

Use PDFInkAnnotation class to add ink annotation.

PDf Ink Annotation

 

 

 

using PDFMosaic;
using System;
using System.Drawing;

namespace PDFInkAnnotationSample
{
    class PDFInkAnnotationSample
    {
        static void Main()
        {
            PDFDocument pdf = new PDFDocument();
            pdf.Pages.Add(new PDFPage(PDFPaperFormat.A4));

            Random rnd = new Random();
            PDFInkList list = new PDFInkList();
            PointF[] f = new PointF[5];
            for (int j = 0; j < 5; ++j)
            {
                int min = rnd.Next(100);
                int max = rnd.Next(100, 600);
                for (int i = 0; i < f.Length; ++i)
                {
                    f[i].X = rnd.Next(min, max);
                    f[i].Y = rnd.Next(min, max);

                }
                list.AddArray(new PDFPointsArray(f));
            }
            PDFInkAnnotation annot = new PDFInkAnnotation(list);
            annot.Contents = "PDF ink annotation";
            annot.Color = new PDFColorRGB(80, 80, 50);

            pdf.Pages[0].Annotations.Add(annot);
            pdf.Save("TestInkAnnotation.pdf", true);
        }
    }
}