Page label editor

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

Edit PDF page labels in Xamarin.Android

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.

Apryse Docs Image

Show the page label editor

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

C#

1public void ShowPageLabelSettingsDialog(FragmentManager fragmentManager, int fromPage, int toPage, int pageCount)
2{
3 var dialog = pdftron.PDF.Dialog.PageLabel.PageLabelDialog.NewInstance(fromPage, toPage, pageCount);
4 dialog.SetStyle((int)DialogFragmentStyle.NoTitle, Resource.Style.PDFTronAppTheme);
5 dialog.Show(fragmentManager, "page_label_dialog");
6}

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:

C#

1public class MyActivity : AppCompatActivity, Android.Arch.Lifecycle.IObserver
2{
3 public void PageLabelObserveOnComplete(AppCompatActivity activity, PDFViewCtrl pdfViewCtrl)
4 {
5 var viewModel = ViewModelProviders.Of(activity).Get(Java.Lang.Class.FromType(typeof(pdftron.PDF.Dialog.PageLabel.PageLabelSettingViewModel))) as pdftron.PDF.Dialog.PageLabel.PageLabelSettingViewModel;
6 viewModel.ObserveOnComplete(activity, this);
7 }
8
9 public void OnChanged(Java.Lang.Object p0)
10 {
11 if (p0 is pdftron.PDF.Tools.Utils.Event)
12 {
13 var someEvent = p0 as pdftron.PDF.Tools.Utils.Event;
14 if (!someEvent.HasBeenHandled)
15 {
16 var actualEvent = someEvent.ContentIfNotHandled;
17 if (actualEvent is pdftron.PDF.Dialog.PageLabel.PageLabelSetting)
18 {
19 var pageLabelSettingEvent = actualEvent as pdftron.PDF.Dialog.PageLabel.PageLabelSetting;
20 pdftron.PDF.Dialog.PageLabel.PageLabelUtils.SetPageLabel(mPdfViewCtrl, pageLabelSettingEvent);
21 }
22 }
23 }
24 }
25}

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales
Add or Edit PDF Page Labels in Xamarin | Apryse documentation