Some test text!

Custom toolkeyboard_arrow_down

Custom Tool

PDFTron 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 here.

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

  1. Creating CustomTool:

    using System;
    using pdftron.PDF;
    using pdftron.PDF.Tools;
    using pdftron.PDF.Tools.Utils;
    using Polygon = pdftronprivate.PDF.Annots.Polygon;
    namespace PDFNetAndroidXamarinSample
        public class CustomTool : RectCreate
            public static ToolManager.IToolModeBase MODE = ToolManager.ToolMode.AddNewMode((int)Annot.Type.e_Polygon);
            public CustomTool(PDFViewCtrl ctrl) : base(ctrl)
            public override ToolManager.IToolModeBase ToolMode
                    return MODE;
            protected override pdftronprivate.PDF.Annot CreateMarkup(pdftronprivate.PDF.PDFDoc doc, pdftronprivate.PDF.Rect bbox)
                var poly = new Polygon(Polygon.Create(doc, (int)Annot.Type.e_Polygon, bbox));
                var color = Utils.Color2ColorPt(Android.Graphics.Color.Red);
                poly.SetColor(color, 3);
                poly.SetVertex(0, new pdftronprivate.PDF.Point(bbox.X1, bbox.Y1));
                poly.SetVertex(1, new pdftronprivate.PDF.Point(bbox.X1, bbox.Y2));
                poly.SetVertex(2, new pdftronprivate.PDF.Point(bbox.X2, bbox.Y2));
                poly.SetVertex(3, new pdftronprivate.PDF.Point(bbox.X2, bbox.Y1));
                poly.IntentName = pdftronprivate.PDF.Annots.PolyLine.EPolygonCloud;
                poly.BorderEffect = pdftronprivate.PDF.Annots.Markup.ECloudy;
                poly.BorderEffectIntensity = 2.0;
                poly.Rect = bbox;
                return poly;
  2. Using the tool:
mToolManager.Tool = new CustomTool(mPdfViewCtrl);

Get the answers you need: Support


Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.