using Spire.Pdf;using Spire.Pdf.Annotations;using System.Collections.Generic;using System.Drawing; namespace InkAnnotation{ class Program { static void Main(string[] args) { //加载PDF文档 PdfDocument pdf = new PdfDocument(); pdf.LoadFromFile("test.pdf"); //获取第一页 PdfPageBase pdfPage = pdf.Pages[0]; //设置墨迹坐标点位置 List<int[]> inkList = new List<int[]>(); int[] intPoints = new int[] { 370,700, 120,720, 110,760, 220,800, 270,790, 350,770, 350,670 }; inkList.Add(intPoints); //添加墨迹注释到PDF页面 PdfInkAnnotation inkannotation = new PdfInkAnnotation(inkList); inkannotation.Color = Color.MediumVioletRed; inkannotation.Border.Width = 6; inkannotation.Opacity = 0.5f; inkannotation.Text = "This is an ink annotation. "; inkannotation.Name = "Manager"; pdfPage.AnnotationsWidget.Add(inkannotation); //保存文档 Pdf.SaveToFile("AddInkAnnotation.pdf",FileFormat.PDF); System.Diagnostics.Process.Start("AddInkAnnotation.pdf"); } }}
vb.net
Imports Spire.PdfImports Spire.Pdf.AnnotationsImports System.Collections.GenericImports System.DrawingNamespace InkAnnotation Class Program Private Shared Sub Main(args As String()) '加载PDF文档 Dim pdf As New PdfDocument() pdf.LoadFromFile("test.pdf") '获取第一页 Dim pdfPage As PdfPageBase = pdf.Pages(0) '设置墨迹坐标点位置 Dim inkList As New List(Of Integer())() Dim intPoints As Integer() = New Integer() {370, 700, 120, 720, 110, 760, _ 220, 800, 270, 790, 350, 770, _ 350, 670} inkList.Add(intPoints) '添加墨迹注释到PDF页面 Dim inkannotation As New PdfInkAnnotation(inkList) inkannotation.Color = Color.MediumVioletRed inkannotation.Border.Width = 6 inkannotation.Opacity = 0.5F inkannotation.Text = "This is an ink annotation. " inkannotation.Name = "Manager" pdfPage.AnnotationsWidget.Add(inkannotation) '保存文档 pdf.SaveToFile("AddInkAnnotation.pdf", FileFormat.PDF) End Sub End ClassEnd Namespace