Some test text!

Annotation toolbar

In this document
chevron_rightIn Xamarin.Android
chevron_rightIn Xamarin.iOS

linkIn Xamarin.Android

Using annotation toolbar in Xamarin.Android is identical to using annotation toolbar in Android. See tutorial here.

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

<pdftron.PDF.Controls.AnnotationToolbar
    android:id="@+id/annotationtoolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:elevation="@dimen/actionbar_elevation" />

To setup and show:

using pdftron.PDF.Controls;

var annotationToolbar = FindViewById<AnnotationToolbar>(Resource.Id.annotationtoolbar);
annotationToolbar.Setup(mToolManager);
annotationToolbar.SetButtonStayDown(true); // for continuous annotation creation
annotationToolbar.Show();
mPdfViewCtrl.Invalidate();

To close the annotation toolbar programmatically call:

annotationToolbar.Close();

Handle rotation:

public override void OnConfigurationChanged(Android.Content.Res.Configuration newConfig)
{
    base.OnConfigurationChanged(newConfig);
    if (annotationToolbar != null && annotationToolbar.IsShowing)
    {
        annotationToolbar.OnConfigurationChanged(newConfig);
    }
}

Hide annotation toolbar items:

// remove text highlight, ink, rectangle and free text tool 
// from AnnotationToolbar and QuickMenu.
mToolManager.DisableToolMode(new ToolManager.ToolMode[] {
    ToolManager.ToolMode.TextHighlight,
    ToolManager.ToolMode.InkCreate,
    ToolManager.ToolMode.RectCreate,
    ToolManager.ToolMode.TextCreate
});

linkIn Xamarin.iOS

Using annotation toolbar in Xamarin.iOS is identical to using annotation toolbar in iOS. See tutorial here.

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

var annotationToolbar = new pdftron.PDF.Controls.AnnotationToolbar(mToolManager);
annotationToolbar.AnnotationToolbarDidCancel += (sender, e) =>
{
    annotationToolbar.Hidden = true;
};
View.AddSubview(annotationToolbar);

// hide annotation toolbar by default
annotationToolbar.Hidden = true;

// position annotation toolbar
annotationToolbar.TranslatesAutoresizingMaskIntoConstraints = false;
NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] {
    annotationToolbar.LeadingAnchor.ConstraintEqualTo(this.View.LeadingAnchor),
    annotationToolbar.WidthAnchor.ConstraintEqualTo(this.View.WidthAnchor),
    annotationToolbar.TopAnchor.ConstraintEqualTo(this.View.LayoutMarginsGuide.TopAnchor)
});

To show:

annotationToolbar.Hidden = false;

Handle rotation:

public override void ViewWillTransitionToSize(CGSize toSize, IUIViewControllerTransitionCoordinator coordinator)
{
    base.ViewWillTransitionToSize(toSize, coordinator);

    coordinator.AnimateAlongsideTransition((obj) =>
    {
        var orientation = UIDevice.CurrentDevice.Orientation;
        if (annotationToolbar != null) {
            annotationToolbar.RotateToOrientation(orientation);
        }
    }, (obj) =>
    {

    });
}