Some test text!

Search
Hamburger Icon

Android / Guides / Page label editor

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.

page-label-dialog

Show the page label editor

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

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

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 void observeOnComplete(final AppCompatActivity activity, final PDFViewCtrl pdfViewCtrl) {
    PageLabelSettingViewModel viewModel = ViewModelProviders.of(activity).get(PageLabelSettingViewModel.class);
    viewModel.observeOnComplete(activity, new Observer<Event<PageLabelSetting>>() {
        @Override
        public void onChanged(@Nullable Event<PageLabelSetting> pageLabelSettingEvent) {
            // Handle the completion event from the page label dialog,
            // and change the page labels in PDFViewCtrl
            if (pageLabelSettingEvent != null && !pageLabelSettingEvent.hasBeenHandled()) {
                PageLabelUtils.setPageLabel(pdfViewCtrl, pageLabelSettingEvent.getContentIfNotHandled());
            }
        }
    });
}

Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales