InkAnnotPaths.cs
// 完毕:
using System;
using System.IO;
using System.Collections.Generic;
using System.Drawing;
using GrapeCity.Documents.Pdf;
using GrapeCity.Documents.Text;
using GrapeCity.Documents.Pdf.Annotations;

namespace DsPdfWeb.Demos.Basics
{
    // 演示如何向 PDF 文档添加墨迹注释,
    // 以及如何使用 InkAnnotation.Paths 属性呈现其内容。
    public class InkAnnotPaths
    {
        public int CreatePDF(Stream stream)
        {
            var doc = new GcPdfDocument();
            var page = doc.NewPage();
            // 注释作者的用户名:
            var user1 = "杰米·史密斯";

            var rc = Common.Util.AddNote(
                "此示例创建墨迹注释并演示如何使用 InkAnnotation.Paths 属性" +
                "",
                page);

            var inkAnnot = new InkAnnotation()
            {
                UserName = user1,
                Rect = new RectangleF(rc.Left, rc.Bottom + 20, 72 * 5, 72 * 2),
                LineWidth = 2,
                Color = Color.DarkBlue,
                Contents = "这是通过 InkAnnotation.Paths 绘制的墨迹注释。"
            };
            float x0 = 80, x = 80, y = rc.Bottom + 24, h = 18, dx = 2, dy = 4, dx2 = 4, w = 10, xoff = 15;

            // 乱写“墨迹注释”文本:

            // i
            var paths = new List<PointF[]>();
            paths.Add(new[] { new PointF(x + w/2, y), new PointF(x + w/2, y + h), new PointF(x + w, y + h*.7f) });
            paths.Add(new[] { new PointF(x + w/2 - dx, y - h/3 + dy), new PointF(x + w/2 + dx, y - h/3) });
            // n
            x += xoff;
            paths.Add(new[] { new PointF(x, y), new PointF(x, y + h), new PointF(x, y + h - dy), new PointF(x + w*0.7f, y),
                new PointF(x + w - dx/2, y + h*.6f), new PointF(x + w, y + h), new PointF(x + w + dx2, y + h*.7f) });
            // k
            x += xoff;
            paths.Add(new[] { new PointF(x, y - h/3), new PointF(x, y + h) });
            paths.Add(new[] { new PointF(x + w, y), new PointF(x + dx, y + h/2 - dy), new PointF(x, y + h/2),
                new PointF(x + dx2, y + h/2 + dy), new PointF(x + w, y + h), new PointF(x + w + dx2, y + h*.7f) });

            // a
            x += xoff * 2;
            paths.Add(new[] { new PointF(x + w, y + dy), new PointF(x + w/2, y), new PointF(x, y + h/2), new PointF(x + w/2, y + h),
                new PointF(x + w, y + dy), new PointF(x + w, y), new PointF(x + w, y + h), new PointF(x + w + dx2, y + h*.7f) });
            // n
            x += xoff;
            paths.Add(new[] { new PointF(x, y), new PointF(x, y + h), new PointF(x, y + h - dy), new PointF(x + w*0.7f, y),
                new PointF(x + w - dx/2, y + h*.6f), new PointF(x + w, y + h), new PointF(x + w + dx2, y + h*.7f) });
            // n
            x += xoff;
            paths.Add(new[] { new PointF(x, y), new PointF(x, y + h), new PointF(x, y + h - dy), new PointF(x + w*0.7f, y),
                new PointF(x + w - dx/2, y + h*.6f), new PointF(x + w, y + h), new PointF(x + w + dx2, y + h*.7f) });
            // o
            x += xoff;
            paths.Add(new[] { new PointF(x + w/2, y), new PointF(x + w/2 - dx, y), new PointF(x, y + h/2), new PointF(x + w/2, y + h),
                new PointF(x + w, y + h/2), new PointF(x + w/2 + dx, y), new PointF(x + w/2, y) });
            // t
            x += xoff;
            paths.Add(new[] { new PointF(x + w/2, y - h/3), new PointF(x + w/2, y + h), new PointF(x + w, y + h*.7f) });
            paths.Add(new[] { new PointF(x, y), new PointF(x + w, y) });
            // a
            x += xoff;
            paths.Add(new[] { new PointF(x + w, y + dy), new PointF(x + w/2, y), new PointF(x, y + h/2), new PointF(x + w/2, y + h),
                new PointF(x + w, y + dy), new PointF(x + w, y), new PointF(x + w, y + h), new PointF(x + w + dx2, y + h*.7f) });
            // t
            x += xoff;
            paths.Add(new[] { new PointF(x + w/2, y - h/3), new PointF(x + w/2, y + h), new PointF(x + w, y + h*.7f) });
            paths.Add(new[] { new PointF(x, y), new PointF(x + w, y) });
            // i
            x += xoff;
            paths.Add(new[] { new PointF(x + w/2, y), new PointF(x + w/2, y + h), new PointF(x + w, y + h*.7f) });
            paths.Add(new[] { new PointF(x + w/2 - dx, y - h/3 + dy), new PointF(x + w/2 + dx, y - h/3) });
            // o
            x += xoff;
            paths.Add(new[] { new PointF(x + w/2, y), new PointF(x + w/2 - dx, y), new PointF(x, y + h/2),
                new PointF(x + w/2, y + h), new PointF(x + w, y + h/2), new PointF(x + w/2 + dx, y), new PointF(x + w/2, y) });
            // n
            x += xoff;
            paths.Add(new[] { new PointF(x, y), new PointF(x, y + h), new PointF(x, y + h - dy), new PointF(x + w*0.7f, y),
                new PointF(x + w - dx/2, y + h*.6f), new PointF(x + w, y + h), new PointF(x + w + dx2, y + h*.7f),
                new PointF(x + w*3, y + h*.4f), new PointF(x + w + dx2, y + h + dy*2), new PointF(x0, y + h + dy)} );
            inkAnnot.Paths = paths;

            page.Annotations.Add(inkAnnot);

            // 完毕:
            doc.Save(stream);
            return doc.Pages.Count;
        }
    }
}