DocumentAlignmentViewController

Swift

@objc(PSPDFDocumentAlignmentViewController)
public final class DocumentAlignmentViewController : UIViewController

A view controller that provides the user interface for aligning two versions of a document.

Customizing the Document Alignment View Controller

The document alignment view controller’s view hierarchy uses tintColor to configure the look of the crosshair and the progress bar. You can customize this look by setting a custom tint color.

You may use ComparisonConfiguration to customize the contents and the look of the generated comparison document. See its documentation for more information.

Receiving the Generated Comparison Document

Once the user aligns both versions of a document, the document alignment view controller will notify the delegate object that a comparison document was generated, or failed to be generated because of an error. You may implement the two methods to hide the document alignment view controller and update your app’s user interface accordingly.

The document alignment view controller also offers an alternative Swift-only API based on the Combine framework that you can use to receive the generated comparison document. It’s equivalent to the delegate protocol and may be used when Combine bindings are more manageable, e.g. in SwiftUI.

PSPDF_EXPORT(PSPDFDocumentAlignmentViewController)

  • Initialize the document alignment view controller with the given two versions of a document and indices of the pages on which the points should be selected in both versions of a document.

    Note

    Initializing the document alignment view controller requires the Comparison component to be enabled for your license.

    Declaration

    Swift

    @objc(initWithOldDocument:pageIndex:newDocument:pageIndex:configuration:)
    public init(oldDocument: Document, pageIndex oldPageIndex: PageIndex, newDocument: Document, pageIndex newPageIndex: PageIndex, configuration: ComparisonConfiguration)

    Parameters

    oldDocument

    The old version of a document.

    oldPageIndex

    The index of the page in the old version of a document.

    newDocument

    The new version of a document.

    newPageIndex

    The index of the page in the new version of a document.

    configuration

    The configuration that will be used to generate a comparison document.

  • Initialize the document alignment view controller with the given two versions of a document. The points will be selected on the first pages of both versions of a document.

    Note

    Initializing the document alignment view controller requires the Comparison component to be enabled for your license.

    Declaration

    Swift

    @objc(initWithOldDocument:newDocument:configuration:)
    public convenience init(oldDocument: Document, newDocument: Document, configuration: ComparisonConfiguration)

    Parameters

    oldDocument

    The old version of a document.

    newDocument

    The new version of a document.

    configuration

    The configuration that will be used to generate a comparison document.

  • The delegate of the document alignment controller.

    Declaration

    Swift

    @objc
    public weak var delegate: DocumentAlignmentViewControllerDelegate?
  • The future that emits a generated comparison document once the user aligns both versions of a document, or an error if generating the comparison document failed.

    Subscribing to this future is equivalent to implementing the documentAlignmentViewController(_:didFinishWithComparisonDocument:) and documentAlignmentViewController(_:didFailWithError:) delegate methods.

    Declaration

    Swift

    public let comparisonDocument: Future<Document, Error>