Some test text!

menu
search
Page labels editor (Android)keyboard_arrow_down

Page label editor

You can choose to edit page labels programmatically or with a graphical UI.

Page label editor

This tutorial only applies to Xamarin.Android.

The PageLabelDialogFragment allows you to add or modify the page labels in a PDF document. Page labels are typically used to describe a page, such as allowing for non-sequential page numbering (such as the inclusion of Roman numerals at the beginning of a book) or the addition of arbitrary labels.

page-label-dialog

linkShow the page label editor

The page label editor can be shown from an activity by calling the following method:

public void ShowPageLabelSettingsDialog(Android.Support.V4.App.FragmentManager fragmentManager, int fromPage, int toPage, int pageCount)
{
    var dialog = pdftron.PDF.Dialog.PageLabel.PageLabelDialog.NewInstance(fromPage, toPage, pageCount);
    dialog.SetStyle((int)DialogFragmentStyle.NoTitle, Resource.Style.CustomAppTheme);
    dialog.Show(fragmentManager, "page_label_dialog");
}

In order to recieve the inputs from the page label editor, you will also need to subscribe to completion events from the page label dialog:

public class MyActivity : AppCompatActivity, Android.Arch.Lifecycle.IObserver
{
    public void PageLabelObserveOnComplete(Android.Support.V7.App.AppCompatActivity activity, PDFViewCtrl pdfViewCtrl)
    {
        var viewModel = ViewModelProviders.Of(activity).Get(Java.Lang.Class.FromType(typeof(pdftron.PDF.Dialog.PageLabel.PageLabelSettingViewModel))) as pdftron.PDF.Dialog.PageLabel.PageLabelSettingViewModel;
        viewModel.ObserveOnComplete(activity, this);
    }

    public void OnChanged(Java.Lang.Object p0)
    {
        if (p0 is pdftron.PDF.Tools.Utils.Event)
        {
            var someEvent = p0 as pdftron.PDF.Tools.Utils.Event;
            if (!someEvent.HasBeenHandled)
            {
                var actualEvent = someEvent.ContentIfNotHandled;
                if (actualEvent is pdftron.PDF.Dialog.PageLabel.PageLabelSetting)
                {
                    var pageLabelSettingEvent = actualEvent as pdftron.PDF.Dialog.PageLabel.PageLabelSetting;
                    pdftron.PDF.Dialog.PageLabel.PageLabelUtils.SetPageLabel(mPdfViewCtrl, pageLabelSettingEvent);
                }
            }
        }
    }
}

Get the answers you need: Support

close

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.

PDFTron Receives USD$71 Million Growth Investment Led By Silversmith Capital Partners

Learn more
close