InkAnnotPaths.vb
'' 完毕:
Imports System.IO
Imports System.Drawing
Imports GrapeCity.Documents.Pdf
Imports GrapeCity.Documents.Pdf.Annotations
Imports GrapeCity.Documents.Text
Imports GrapeCity.Documents.Drawing

'' 演示如何向 PDF 文档添加墨迹注释,
'' 以及如何使用 InkAnnotation.Paths 属性呈现其内容。
Public Class InkAnnotPaths
    Function CreatePDF(ByVal stream As Stream) As Integer
        Dim doc = New GcPdfDocument()
        Dim page = doc.NewPage()
        '' 注释作者的用户名:
        Dim user1 = "杰米·史密斯"

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

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

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

        '' i
        Dim paths As List(Of PointF()) = New List(Of PointF())
        paths.Add({New PointF(x + w / 2, y), New PointF(x + w / 2, y + h), New PointF(x + w, y + h * 0.7F)})
        paths.Add({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 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 * 0.6F), New PointF(x + w, y + h), New PointF(x + w + dx2, y + h * 0.7F)})
        '' k
        x += xoff
        paths.Add({New PointF(x, y - h / 3), New PointF(x, y + h)})
        paths.Add({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 * 0.7F)})

        '' a
        x += xoff * 2
        paths.Add({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 * 0.7F)})
        '' n
        x += xoff
        paths.Add({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 * 0.6F), New PointF(x + w, y + h), New PointF(x + w + dx2, y + h * 0.7F)})
        '' n
        x += xoff
        paths.Add({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 * 0.6F), New PointF(x + w, y + h), New PointF(x + w + dx2, y + h * 0.7F)})
        '' o
        x += xoff
        paths.Add({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 PointF(x + w / 2, y - h / 3), New PointF(x + w / 2, y + h), New PointF(x + w, y + h * 0.7F)})
        paths.Add({New PointF(x, y), New PointF(x + w, y)})
        '' a
        x += xoff
        paths.Add({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 * 0.7F)})
        '' t
        x += xoff
        paths.Add({New PointF(x + w / 2, y - h / 3), New PointF(x + w / 2, y + h), New PointF(x + w, y + h * 0.7F)})
        paths.Add({New PointF(x, y), New PointF(x + w, y)})
        '' i
        x += xoff
        paths.Add({New PointF(x + w / 2, y), New PointF(x + w / 2, y + h), New PointF(x + w, y + h * 0.7F)})
        paths.Add({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 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 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 * 0.6F), New PointF(x + w, y + h), New PointF(x + w + dx2, y + h * 0.7F),
                New PointF(x + w * 3, y + h * 0.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
    End Function
End Class