PSPDFViewState


@interface PSPDFViewState : PSPDFModel <NSSecureCoding>

Represents a certain view state (document position, zoom) of a PSPDFDocument.

Note

Important: If an instance of this class has a viewPort, that view port is always defined in the coordinate system of the page. For pages that are rotated by ± 90 degrees, this implies that the aspect ratio of the viewPort will appear to be “flipped” compared to the UI.
  • Designated initializer.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithPageIndex:(NSUInteger)pageIndex
                                     viewPort:(CGRect)viewPort
                               selectionState:
                                   (nullable PSPDFSelectionState *)selectionState;

    Swift

    init(pageIndex: UInt, viewPort: CGRect, selectionState: PSPDFSelectionState?)
  • Initializes a PSPDFViewState with the specified page index and selection state only. The view port will be set to CGRectNull.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithPageIndex:(NSUInteger)pageIndex
                               selectionState:
                                   (nullable PSPDFSelectionState *)selectionState;

    Swift

    convenience init(pageIndex: UInt, selectionState: PSPDFSelectionState?)
  • Initializes a PSPDFViewState with the specified page index and view port only. The selection state will be set to nil.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithPageIndex:(NSUInteger)pageIndex
                                     viewPort:(CGRect)viewPort;

    Swift

    convenience init(pageIndex: UInt, viewPort: CGRect)
  • Initializes a PSPDFViewState with a page index only. The view port and selection state will be set to CGRectNull and nil respectively.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithPageIndex:(NSUInteger)pageIndex;

    Swift

    convenience init(pageIndex: UInt)
  • Visible Page.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSUInteger pageIndex;

    Swift

    var pageIndex: UInt { get }
  • The effectively visible rect of the PDF in PDF coordinates — CGRectNull if the view was fully visible and not displayed in continuous scrolling mode. - note: Due to the nature of continuous scrolling, even a fully zoomed out page can have a view–port. This is necessary to preserve a scrolling offset in documents where more than one page fits on the screen at once.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGRect viewPort;

    Swift

    var viewPort: CGRect { get }
  • Whether or not the receiver has a restorable view port.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL hasViewPort;

    Swift

    var hasViewPort: Bool { get }
  • The view’s selection state.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) PSPDFSelectionState *selectionState;

    Swift

    var selectionState: PSPDFSelectionState? { get }
  • Compares the receiver to another viewstate, allowing for the specified leeway if both have a viewport. - parameter: other The object to compare to — may be nil. - parameter: leeway How much each dimension of the viewport may differ.

    Declaration

    Objective-C

    - (BOOL)isEqualToViewState:(nullable PSPDFViewState *)other
                  withAccuracy:(CGFloat)leeway;

    Swift

    func isEqual(to other: PSPDFViewState?, withAccuracy leeway: CGFloat) -> Bool

    Parameters

    other

    The object to compare to — may be nil.

    leeway

    How much each dimension of the viewport may differ.