Custom Tool

Apryse SDK gives you the ability to create your own tools should you need one.

Creating a custom annotation tool in Xamarin.Android

Creating a new tool in Xamarin.Android is similar to creating a new tool in Android. See tutorial in Android guides.

For example, the equivalent of the example provided in the Android guide will be:

  1. Creating CustomTool:

C#

1using System;
2
3using pdftron.PDF;
4using pdftron.PDF.Tools;
5using pdftron.PDF.Tools.Utils;
6
7using Polygon = pdftronprivate.PDF.Annots.Polygon;
8
9namespace PDFNetAndroidXamarinSample
10{
11 public class CustomTool : RectCreate
12 {
13 public static ToolManager.IToolModeBase MODE = ToolManager.ToolMode.AddNewMode((int)Annot.Type.e_Polygon);
14
15 public CustomTool(PDFViewCtrl ctrl) : base(ctrl)
16 {
17
18 }
19
20 public override ToolManager.IToolModeBase ToolMode
21 {
22 get
23 {
24 return MODE;
25 }
26 }
27
28 protected override pdftronprivate.PDF.Annot CreateMarkup(pdftronprivate.PDF.PDFDoc doc, pdftronprivate.PDF.Rect bbox)
29 {
30 var poly = new Polygon(Polygon.Create(doc, (int)Annot.Type.e_Polygon, bbox));
31 var color = Utils.Color2ColorPt(Android.Graphics.Color.Red);
32 poly.SetColor(color, 3);
33 poly.SetVertex(0, new pdftronprivate.PDF.Point(bbox.X1, bbox.Y1));
34 poly.SetVertex(1, new pdftronprivate.PDF.Point(bbox.X1, bbox.Y2));
35 poly.SetVertex(2, new pdftronprivate.PDF.Point(bbox.X2, bbox.Y2));
36 poly.SetVertex(3, new pdftronprivate.PDF.Point(bbox.X2, bbox.Y1));
37 poly.IntentName = pdftronprivate.PDF.Annots.PolyLine.EPolygonCloud;
38 poly.BorderEffect = pdftronprivate.PDF.Annots.Markup.ECloudy;
39 poly.BorderEffectIntensity = 2.0;
40 poly.Rect = bbox;
41
42 return poly;
43 }
44 }
45}
  1. Using the tool:

C#

1mToolManager.Tool = new CustomTool(mPdfViewCtrl);

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales