For the complete documentation index, see llms.txt. This page is also available as Markdown.

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:

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
        {
            get
            {
                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;
        }
    }
}
  1. Using the tool:

Creating a custom annotation tool in Xamarin.iOS

It is possible to create a new tool via C# API if you are looking for very simple tools that do not require much UI. Otherwise, you will have to customize the tools source code in Objective-C. The following section describes how to create a simple tool via C# API.

  1. Creating CustomTool:

  1. Using the tool:

To learn more about how to modify the tools source code in Objective-C, check out this guide: Creating a new tool.

Last updated

Was this helpful?