Crop page dialog

With PDFTron library, you can crop pages manually or automatically, as well as reset pages to their original size. The UserCropDialogFragment class shows a dialog for users to adjust the page's crop box. The user can also apply the current page's crop box to a subset of pages or even to all pages in the document.

Showing user crop pages dialog

To create a new instance of the user crop pages dialog fragment, call newInstance() and set the PDFViewCtrl:

UserCropDialogFragment userCropDialogFragment = UserCropDialogFragment.newInstance()
userCropDialogFragment.setStyle(DialogFragment.STYLE_NO_TITLE,;, "user_crop_pages_dialog");

To apply the crop box, make sure you have Page.e_user_crop as the default page box:


You can also set a listener via setOnUserCropDialogDismissListener(OnUserCropDialogDismissListener) to be notified when the user crop dialog is dismissed.

UserCropDialogFragment does not crop pages permanently, it may not handled well by other PDF viewer. To crop pages permanently, see cropping pages permanently

Cropping pages automatically

To crop pages automatically, you can simply use the utility API called UserCropUtilities.AutoCropInBackgroundTask. It crops the edges of the document based on the position of the content.

UserCropUtilities.AutoCropInBackgroundTask autoCropTask =
    new UserCropUtilities.AutoCropInBackgroundTask(getContext(), mPdfViewCtrl,
        new UserCropUtilities.AutoCropInBackgroundTask.AutoCropTaskListener() {
            public void onAutoCropTaskDone() {
                // auto crop task was finished or cancelled

Removing user crop boxes

If, after cropping pages, you wish to reset page size, you can use the utility function UserCropUtilities.removeUserCropFromPage(Page).

Permanently cropping pages

Cropping pages through above methods are in user-level. User-level page-cropping may not be handled well by other PDF viewers. To apply crop pages permanently use UserCropUtilities.cropDoc(PDFDoc).