Document Page Binding

PDF documents support a metaphorical page binding, which is used when pages are laid out horizontally. Many languages use a left-to-right script, which calls for a page binding on the left edge. However, binding on the right edge is preferable for right-to-left scripts such Arabic and Hebrew and several East Asian scripts. The page binding is used with horizontal scrolling and in the thumbnails view. It has no effect when using vertical scrolling unless double-page mode is also enabled.

The page binding ought to be specified by the author when a PDF is created. However, sometimes this is not done, in which case most PDF readers will default to a left-edge binding.

Updating the Page Binding Programmatically

PSPDFKit for iOS uses the PSPDFDocument.pageBinding property to infer how a document should be presented to the user. Possible values are:

  • PSPDFPageBindingLeft — the document flows from left to right
  • PSPDFPageBindingRight — the document flows from right to left
  • PSPDFPageBindingUnknown — the document does not explicitly define a page binding, so the behavior is the same as it is with PSPDFPageBindingLeft

The following snippet updates the page binding property of a document:

1
2
3
let document = // ...
document.pageBinding = .rightEdge
try? document.save()
1
2
3
PSPDFDocument *document = // ...
document.pageBinding = PSPDFPageBindingRightEdge;
[document saveWithOptions:nil error:nil];

When the page binding of a document is updated, -[PSPDFViewController reloadData] needs to be called so that the user interface is updated to match the new value. Please note that new values set to the property will not be persisted until the document is saved — which can happen either through an explicit call to -[PSPDFDocument saveWithOptions:error:] or when a checkpoint trigger is fired — if document checkpointing is enabled.

Affected Components

The following UI components will change their behavior based on the current document’s page binding. Keep in mind that all other UI components that aren’t mentioned here will follow the layout direction that is provided by the currently selected locale.

Document View

  • When in horizontal scrolling mode, documents with the PSPDFPageBindingRightEdge page binding will scroll from right to left instead of the default left to right.
  • When in vertical double-page mode, documents with the PSPDFPageBindingRightEdge page binding will have their displayed page order flipped pairwise. So the right page will be the first one, the left page will be the second one, and so on.

The Thumbnail Bar

  • In documents with the PSPDFPageBindingRightEdge page binding, the order of thumbnails will be flipped, so the first page will be on the right and the last page will be on the left.
  • This also applies when in double-page mode, where the order of the pages in the pairs is also flipped.

The Thumbnail Grid

  • In documents with the PSPDFPageBindingRightEdge page binding, the thumbnails will be laid out from right to left, so the first page will be on the top right.

Updating the Page Binding via the UI

PSPDFKit 8.5 for iOS introduced the ability to edit a document’s page binding directly from the PSPDFDocumentInfoViewController.

Since changing the page binding of a document requires it to be reloaded for the changes to be visible to the user, if you implement a PSPDFDocumentInfoViewController instance manually (as in not being invoked by PSPDFViewController directly), make sure you also implement the relevant PSPDFDocumentInfoViewControllerDelegate methods to reload the document when appropriate.