Page label editor: add or modify PDF pages in 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:

1public void showPageLabelSettingsDialog(FragmentManager fragmentManager, int fromPage, int toPage, int pageCount) {
2 PageLabelDialog dialog = PageLabelDialog.newInstance(fromPage, toPage, pageCount);
3 dialog.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.PDFTronAppTheme);
4 dialog.show(fragmentManager, PageLabelDialog.TAG);
5}

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:

1public void observeOnComplete(final AppCompatActivity activity, final PDFViewCtrl pdfViewCtrl) {
2 PageLabelSettingViewModel viewModel = ViewModelProviders.of(activity).get(PageLabelSettingViewModel.class);
3 viewModel.observeOnComplete(activity, new Observer<Event<PageLabelSetting>>() {
4 @Override
5 public void onChanged(@Nullable Event<PageLabelSetting> pageLabelSettingEvent) {
6 // Handle the completion event from the page label dialog,
7 // and change the page labels in PDFViewCtrl
8 if (pageLabelSettingEvent != null && !pageLabelSettingEvent.hasBeenHandled()) {
9 PageLabelUtils.setPageLabel(pdfViewCtrl, pageLabelSettingEvent.getContentIfNotHandled());
10 }
11 }
12 });
13}

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales