PDF Mosaic: How to add ink annotation to PDF documents


Home       Features       Download       Tutorial       Version History       License       Source Code

 

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

Use PDFInkAnnotation class to add 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);
        }
    }
}

 


Home       Features       Download       Tutorial       Version History       License       Source Code