PSPDFComparisonProcessor

Objective-C


@interface PSPDFComparisonProcessor : NSObject

Swift

class ComparisonProcessor : NSObject

An object that can be used to generate a comparison document between two versions of a document.

Customizing the Comparison Document

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

Aligning the Documents

In case the two versions of a document are not perfectly aligned, the comparison processor accepts an optional transformation matrix that describes how the page in the new version of a document is aligned in relation to the page in the old version of a document.

You may either provide an already computed transformation matrix or two sets of equivalent points from both versions of a document and let the comparison processor automatically compute the transformation matrix.

You may also use the DocumentAlignmentViewController from the PSPDFKitUI framework to initiate a process where users can visually select the two sets of points themselves. See its documentation for more information.

  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Initialize the comparison processor with the given configuration.

    Note

    Initializing the comparison processor requires the Comparison component to be enabled for your license.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithConfiguration:
        (nonnull PSPDFComparisonConfiguration *)configuration;

    Swift

    init(configuration: PSPDFComparisonConfiguration)

    Parameters

    configuration

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

  • Generate a comparison document by overlaying a new version of a page onto an old version of the same page.

    The generated comparison document will contain all other pages from the old version of a document at their original indices, and it will have the same security options as the old version of a document.

    @returns A comparison document created with the given parameters and the configuration given at initialization, or nil if an error occurs.

    Declaration

    Objective-C

    - (nullable PSPDFDocument *)
        comparisonDocumentWithOldDocument:(nonnull PSPDFDocument *)oldDocument
                                pageIndex:(PSPDFPageIndex)oldDocumentPageIndex
                              newDocument:(nonnull PSPDFDocument *)newDocument
                                pageIndex:(PSPDFPageIndex)newDocumentPageIndex
                                transform:(CGAffineTransform)transform
                                    error:(NSError *_Nullable *_Nullable)error;

    Parameters

    oldDocument

    The old version of a document.

    oldDocumentPageIndex

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

    newDocument

    The new version of a document.

    newDocumentPageIndex

    The index of the page in the new version of a document. This page will be auto-rotated to match the rotation of the equivalent page in the old version of a document.

    transform

    The transformation matrix that describes how the page in the new version of a document is aligned in relation to the page in the old version of a document. Use .identity if the pages are perfectly aligned.

    error

    If generating a comparison document fails, upon return contains an error object that describes the problem.

  • Generate a comparison document by overlaying a new version of a page onto an old version of the same page.

    The generated comparison document will contain all other pages from the old version of a document at their original indices, and it will have the same security options as the old version of a document.

    @returns A comparison document created with the given parameters and the configuration given at initialization, or nil if an error occurs.

    Declaration

    Objective-C

    - (nullable PSPDFDocument *)
        comparisonDocumentWithOldDocument:(nonnull PSPDFDocument *)oldDocument
                                pageIndex:(PSPDFPageIndex)oldDocumentPageIndex
                                   points:(nonnull NSArray<NSValue *> *)
                                              oldDocumentPoints
                              newDocument:(nonnull PSPDFDocument *)newDocument
                                pageIndex:(PSPDFPageIndex)newDocumentPageIndex
                                   points:(nonnull NSArray<NSValue *> *)
                                              newDocumentPoints
                                    error:(NSError *_Nullable *_Nullable)error;

    Parameters

    oldDocument

    The old version of a document.

    oldDocumentPageIndex

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

    oldDocumentPoints

    The array of three reference points in the PDF coordinate space of the page in the old version of a document.

    newDocument

    The new version of a document.

    newDocumentPageIndex

    The index of the page in the new version of a document. This page will be auto-rotated to match the rotation of the equivalent page in the old version of a document.

    newDocumentPoints

    The array of three reference points in the PDF coordinate space of the page in the new version of a document, equivalent to the points in the old version of a document.

    error

    If generating a comparison document fails, upon return contains an error object that describes the problem.

  • Generate a comparison document by overlaying a new version of a page onto an old version of the same page.

    Declaration

    Swift

    public func comparisonDocument(oldDocument: Document, pageIndex oldDocumentPageIndex: PageIndex = 0, newDocument: Document, pageIndex newDocumentPageIndex: PageIndex = 0, transform: CGAffineTransform = .identity) throws -> Document

    Parameters

    oldDocument

    The old version of a document.

    oldDocumentPageIndex

    The index of the page in the old version of a document. Default: 0.

    newDocument

    The new version of a document.

    newDocumentPageIndex

    The index of the page in the new version of a document. This page will be auto-rotated to match the rotation of the equivalent page in the old version of a document. Default: 0.

    transform

    The affine transformation matrix that describes how the page in the new version of a document is aligned in relation to the page in the old version of a document. Use .identity if the pages are perfectly aligned. Default: .identity.

    Return Value

    A comparison document created with the given parameters and the configuration given at initialization.

  • Generate a comparison document by overlaying a new version of a page onto an old version of the same page.

    Declaration

    Swift

    public func comparisonDocument(oldDocument: Document, pageIndex oldDocumentPageIndex: PageIndex = 0, points oldDocumentPoints: [CGPoint], newDocument: Document, pageIndex newDocumentPageIndex: PageIndex = 0, points newDocumentPoints: [CGPoint]) throws -> Document

    Parameters

    oldDocument

    The old version of a document.

    oldDocumentPageIndex

    The index of the page in the old version of a document. Default: 0.

    oldDocumentPoints

    The array of three reference points in the PDF coordinate space of the page in the old version of a document.

    newDocument

    The new version of a document.

    newDocumentPageIndex

    The index of the page in the new version of a document. This page will be auto-rotated to match the rotation of the equivalent page in the old version of a document. Default: 0.

    newDocumentPoints

    The array of three reference points in the PDF coordinate space of the page in the new version of a document, equivalent to the points in the old version of a document.

    Return Value

    A comparison document created with the given parameters and the configuration given at initialization.