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 as 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.
Update the Page Binding Programmatically
PSPDFKit for iOS uses the
Document.pageBinding property to infer how a document should be presented to the user. Possible values are:
.leftEdge— the document flows from left to right
.rightEdge— the document flows from right to left
.unknown— the document does not explicitly define a page binding, so the behavior is the same as it is with
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,
PDFViewController.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
Document.save(options:) or when a checkpoint trigger is fired — if document checkpointing is enabled.
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.
- When in horizontal scrolling mode, documents with the
.rightEdgepage binding will scroll from right to left instead of the default left to right.
- When in vertical double-page mode, documents with the
.rightEdgepage 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
.rightEdgepage 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
.rightEdgepage binding, the thumbnails will be laid out from right to left, so the first page will be on the top right.
Update the Page Binding via the UI
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
PDFDocumentInfoViewController instance manually (as in not being invoked by
PDFViewController directly), make sure you also implement the relevant
PDFDocumentInfoViewControllerDelegate methods to reload the document when appropriate.