Some test text!

menu
Page label editorkeyboard_arrow_down

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

linkShow 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());
            }
        }
    });
}

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.

Join our upcoming webinar to learn about how to collaborate on videos frame by frame directly in your browser

Save your seat
close