public void TestInkAnnotation() { Document document = new Document(); document.Pages.Add(new Page(PaperFormat.A4)); Random rnd = new Random(); InkList list = new InkList(); 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 PointsArray(f)); } InkAnnotation annot = new InkAnnotation(list); annot.Contents = "PDF ink annotation"; annot.Color = new ColorRGB(80, 80, 50); document.Pages[0].Annotations.Add(annot); document.Save(OutputFolder + @"\TestInkAnnotation.pdf"); document.Dispose(); //Process.Start("TestInkAnnotation.pdf"); }
/// <summary> /// Initializes a new instance of the Bytescout.PDF.InkAnnotation class. /// </summary> /// <param name="inkList">The Bytescout.PDF.InkList representing a stroked path.</param> public InkAnnotation(InkList inkList) : base(null) { if (inkList == null) { throw new ArgumentNullException(); } if (inkList.Page != null) { _inkList = new InkList(); for (int i = 0; i < inkList.Count; ++i) { _inkList.AddArray(new PointsArray(inkList[i].ToArray())); } } else { _inkList = inkList; } _inkList.ChangedInkList += changedInkList; Dictionary.AddItem("Subtype", new PDFName("Ink")); Dictionary.AddItem("InkList", _inkList.Array); _borderStyle = new AnnotationBorderStyle(); Dictionary.AddItem("BS", _borderStyle.GetDictionary()); Color = new ColorRGB(0, 0, 0); }
public void TestPolygonAndPolylineAnnotation() { Document document = new Document(); document.Pages.Add(new Page(PaperFormat.A4)); Random rnd = new Random(); InkList list = new InkList(); PointF[] f = new PointF[10]; for (int j = 0; j < 10; ++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 PointsArray(f)); } PolygonAnnotation annotation = new PolygonAnnotation(list[0]); PolylineAnnotation annotation1 = new PolylineAnnotation(list[1]); annotation1.StartLineStyle = LineEndingStyle.Circle; annotation1.EndLineStyle = LineEndingStyle.RClosedArrow; annotation1.BackgroundColor = new ColorRGB((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255)); annotation1.Contents = "PDF polygon annotation"; annotation.BackgroundColor = new ColorRGB((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255)); annotation.Color = new ColorRGB((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255)); annotation1.Color = new ColorRGB((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255)); annotation1.Contents = "PDF polyline annotation"; document.Pages[0].Annotations.Add(annotation); document.Pages[0].Annotations.Add(annotation1); document.Save(OutputFolder + @"\TestPolygonAndPolylineAnnotation.pdf"); document.Dispose(); //Process.Start("TestPolygonAndPolylineAnnotation.pdf"); }