Thumbnail slider

You can use the slider to get a thumbnail review of pages before they are actually shown in the viewer.

Adding PDF page slider in Xamarin.iOS

This tutorial only applies to Xamarin.iOS. See Xamarin.Android equivalent here .

The PTThumbnailSliderViewController class allows the user to quickly navigate through a document. When using the slider control, a small page preview pop will be shown on top of the thumbnail slider.

Note: If you are using the new UI, we recommend the PTDocumentSliderViewController class, which displays a scroll indicator for the current scroll position and allows the user to quickly skip through pages.

Apryse Docs Image

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

Show a thumbnail slider

To create and set up a thumbnail slider, supply a PTPDFViewCtrl instance to the PTThumbnailSliderViewController designated initializer:

C#

1var thumbnailSlider = new pdftron.PDF.Controls.PTThumbnailSliderViewController(mPdfViewCtrl);
2
3AddChildViewController(thumbnailSlider);
4View.AddSubview(thumbnailSlider.View);
5
6thumbnailSlider.View.TranslatesAutoresizingMaskIntoConstraints = false;
7
8NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] {
9 thumbnailSlider.View.LeadingAnchor.ConstraintEqualTo(this.View.LeadingAnchor),
10 thumbnailSlider.View.WidthAnchor.ConstraintEqualTo(this.View.WidthAnchor),
11 thumbnailSlider.View.BottomAnchor.ConstraintEqualTo(this.View.BottomAnchor)
12});
13thumbnailSlider.DidMoveToParentViewController(this);

Populate with thumbnail images

The thumbnail images shown in the thumbnail slider 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 pdfViewCtrl:gotThumbAsync:thumbImage: method.

In your class adopting the PTPDFViewCtrlDelegate protocol (usually the same view controller containing the thumbnail slider view controller), add the following:

C#

1mPdfViewCtrl.GotThumbAsync += (sender, e) =>
2{
3 if (e.Image == null)
4 {
5 return;
6 }
7 this.thumbnailSlider?.SetThumbnail(e.Image, e.Page_num);
8};

Customization

The PTThumbnailSliderViewController provides a flexible API for displaying buttons on either side of the slider control. This is possible with the following properties:

LeadingToolbarItem - a single UIBarButtonItem to the left of the slider.LeadingToolbarItems - an array of UIBarButtonItems to the left of the slider.TrailingToolbarItem - a single UIBarButtonItem to the right of the slider.TrailingToolbarItems - an array of UIBarButtonItems to the right of the slider.

It is also possible to remove these buttons by setting the appropriate property to nil.

For example, to show a button to present a PTThumbnailsViewController on the left of the slider, and a button to present a PTNavigationListsViewController on the right:

C#

1// add a custom UIBarButtonItem to the left of the thumbnail slider
2thumbnailSlider.LeadingToolbarItem = new UIBarButtonItem(UIImage.FromFile("icon.png"), UIBarButtonItemStyle.Plain, (sender, e) => {
3 // perform custom action
4});
5
6// add an array of UIBarButtonItems to the right of the slider
7var button1 = new UIBarButtonItem(UIImage.FromFile("icon1.png"), UIBarButtonItemStyle.Plain, (sender, e) => {
8 // perform custom action
9});
10var button2 = new UIBarButtonItem(UIImage.FromFile("icon2.png"), UIBarButtonItemStyle.Plain, (sender, e) => {
11 // perform custom action
12});
13documentViewController.ThumbnailSliderController.TrailingToolbarItems = new UIBarButtonItem[] {button1, button2};
14
15// remove the buttons from the left of the slider by setting the property to null
16documentViewController.ThumbnailSliderController.LeadingToolbarItems = null;

The thumbnail slider delegate

The PTThumbnailSliderViewDelegate protocol allows the adopting class (usually the containing view controller, as in this guide) to be notified when the user is actively using the thumbnail slider. The thumbnail slider already handles changing the current page in response to user actions, but the delegate methods can be used to hide or show other content as appropriate.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales