Some test text!

View thumbnailskeyboard_arrow_down

Manipulate pages with thumbnail browser on iOS

The PTThumbnailsViewController class allows users to view and navigate the pages of a PTPDFViewCtrl as well as re-arrange and remove pages.

Thumbnails view controller

The page thumbnails control is part of the Tools library, so make sure you have added the Tools library to your project.

linkShow a page thumbnails view controller

To create a new page thumbnails view controller instance and display it from another view controller, supply a PTPDFViewCtrl instance to the PTThumbnailsViewController designated initializer:

// Initialize thumbnails view controller with a PTPDFViewCtrl instance.
let thumbnailsViewController = PTThumbnailsViewController(pdfViewCtrl: pdfViewCtrl)

let navigationController = UINavigationController(rootViewController: thumbnailsViewController)
self.present(navigationController, animated: true, completion: nil)
The thumbnails view controller does not create its own top navigation bar, so it must be pushed onto a navigation controller's stack in order for the top navigation bar and 'Edit' button to be shown.

linkPopulate the view controller with thumbnail images

The thumbnail images shown in the thumbnails view controller are generated by the GetThumbAsync: method of the PTPDFViewCtrl class. When ready, the thumbnail images are provided to the pdfviewCtrl's delegate via the GotThumbAsync:thumbImage: method.

In your class adopting the PTPDFViewCtrlDelegate protocol (usually the same view controller presenting the thumbnails view controller), add the following:

func pdfViewCtrl(_ pdfViewCtrl: PTPDFViewCtrl!, gotThumbAsync page_num: Int32, thumbImage image: UIImage!) {
    // Ensure thumbnails view controller is presented.
    if self.thumbnailsViewController.presentingViewController != nil {
        self.thumbnailsViewController.setThumbnail(image, forPage: Int(page_num))

linkInteract with the view controller

Pages can be re-arranged and removed in edit-mode, which is activated by the 'Edit' button in the navigation bar. Long-pressing and dragging allows the user to move a page to a different location in the same document, and tapping one or more documents selects them for removal with the trash can icon. The user is prompted for confirmation before any pages are permanently removed.

Get the answers you need: Support


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 live demo to learn about use cases & capabilities for WebViewer

Learn more