Other Functions

The following functions are available globally.

  • A helper to quickly determine if a coordinated data provider provides conflict resolution at a given moment.

    Declaration

    Objective-C

    static inline BOOL PSPDFConflictResolutionAvailableForDataProvider(
        id<PSPDFCoordinatedFileDataProviding> _Nonnull dataProvider)

    Swift

    func PSPDFConflictResolutionAvailableForDataProvider(_ dataProvider: PSPDFCoordinatedFileDataProviding) -> Bool

    Parameters

    dataProvider

    The data provider to check.

    Return Value

    YES if conflict resolution APIs are implemented and conflict resolution is currently possible. NO in all other cases.

  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT CTTextAlignment PSPDFTextAlignmentToCTTextAlignment(NSTextAlignment nsTextAlignment)

    Swift

    func PSPDFTextAlignmentToCTTextAlignment(_ nsTextAlignment: NSTextAlignment) -> CTTextAlignment
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT CGRect PSPDFEdgeInsetInsetRect(CGRect rect, UIEdgeInsets insets)

    Swift

    func PSPDFEdgeInsetInsetRect(_ rect: CGRect, _ insets: NSEdgeInsets) -> CGRect
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT NSString *NSStringFromPSPDFEdgeInset(UIEdgeInsets insets)

    Swift

    func NSStringFromPSPDFEdgeInset(_ insets: NSEdgeInsets) -> String!
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT UIEdgeInsets PSPDFEdgeInsetFromString(NSString *string)

    Swift

    func PSPDFEdgeInsetFromString(_ string: String!) -> NSEdgeInsets
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT NSString *PSPDF_NSStringFromCGPoint(CGPoint point)

    Swift

    func PSPDF_NSStringFromCGPoint(_ point: CGPoint) -> String!
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT NSString *PSPDF_NSStringFromCGSize(CGSize size)

    Swift

    func PSPDF_NSStringFromCGSize(_ size: CGSize) -> String!
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT NSString *PSPDF_NSStringFromCGRect(CGRect rect)

    Swift

    func PSPDF_NSStringFromCGRect(_ rect: CGRect) -> String!
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT NSString *PSPDF_NSStringFromCGAffineTransform(CGAffineTransform transform)

    Swift

    func PSPDF_NSStringFromCGAffineTransform(_ transform: CGAffineTransform) -> String!
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT CGPoint PSPDF_CGPointFromString(NSString *string)

    Swift

    func PSPDF_CGPointFromString(_ string: String!) -> CGPoint
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT CGSize PSPDF_CGSizeFromString(NSString *string)

    Swift

    func PSPDF_CGSizeFromString(_ string: String!) -> CGSize
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT CGRect PSPDF_CGRectFromString(NSString *string)

    Swift

    func PSPDF_CGRectFromString(_ string: String!) -> CGRect
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT CGAffineTransform PSPDF_CGAffineTransformFromString(NSString *string)

    Swift

    func PSPDF_CGAffineTransformFromString(_ string: String!) -> CGAffineTransform
  • Converts an array of glyphs to a string.

    Declaration

    Objective-C

    extern NSString *_Nonnull PSPDFStringFromGlyphs(
        NSArray<PSPDFGlyph *> *_Nullable glyphs)

    Swift

    func PSPDFStringFromGlyphs(_ glyphs: [PSPDFGlyph]?) -> String
  • Returns the bounding box that includes all glyphs.

    Declaration

    Objective-C

    extern CGRect
    PSPDFBoundingBoxFromGlyphs(NSArray<PSPDFGlyph *> *_Nullable glyphs)

    Swift

    func PSPDFBoundingBoxFromGlyphs(_ glyphs: [PSPDFGlyph]?) -> CGRect

    Return Value

    Rect encompassing all glyphs or CGRectZero if glyphs is empty.

  • Global helper to convert glyphs to rects.

    Declaration

    Objective-C

    extern NSArray<NSValue *> *_Nonnull PSPDFRectsFromGlyphs(
        NSArray<PSPDFGlyph *> *_Nullable glyphs, CGRect *_Nonnull boundingBox)

    Swift

    func PSPDFRectsFromGlyphs(_ glyphs: [PSPDFGlyph]?, _ boundingBox: UnsafeMutablePointer<CGRect>) -> [NSValue]
  • Returns an NSRange representing the glyphs in glyphs, assuming they are in ascending order of their indexOnPage. If glyphs is not sorted, this method this method will return a wrong result. PSPDFInvalidGlyphRange is returned an empty array, or if the last glyph has an indexOnPage that is prior to the first one.

    Declaration

    Objective-C

    extern NSRange PSPDFRangeFromGlyphs(NSArray<PSPDFGlyph *> *_Nonnull glyphs)

    Swift

    func PSPDFRangeFromGlyphs(_ glyphs: [PSPDFGlyph]) -> NSRange
  • Calculates the bounding box from lines.

    Declaration

    Objective-C

    extern CGRect PSPDFBoundingBoxFromLines(NSArray *_Nonnull lines,
                                            CGFloat lineWidth)

    Swift

    func PSPDFBoundingBoxFromLines(_ lines: [Any], _ lineWidth: CGFloat) -> CGRect

    Parameters

    lines

    Either an NSArray <PSPDFPointArray *> or NSArray <NSArray <NSValue *> *>.

  • Will convert view lines to PDF lines (operates on every point)

    Declaration

    Objective-C

    extern NSArray<NSArray<NSValue *> *> *_Nonnull PSPDFConvertViewLinesToPDFLines(
        NSArray<NSArray<NSValue *> *> *_Nonnull lines,
        PSPDFPageInfo *_Nonnull pageInfo, CGRect viewBounds)

    Swift

    func PSPDFConvertViewLinesToPDFLines(_ lines: [[NSValue]], _ pageInfo: PSPDFPageInfo, _ viewBounds: CGRect) -> [[NSValue]]
  • Converts a single line of boxed PSPDFDrawingPoints.

    Declaration

    Objective-C

    extern NSArray<NSValue *> *_Nonnull PSPDFConvertViewLineToPDFLines(
        NSArray<NSValue *> *_Nonnull line, PSPDFPageInfo *_Nonnull pageInfo,
        CGRect bounds)

    Swift

    func PSPDFConvertViewLineToPDFLines(_ line: [NSValue], _ pageInfo: PSPDFPageInfo, _ bounds: CGRect) -> [NSValue]
  • Will convert PDF lines to view lines (arrays of PSPDFDrawingPoints) (operates on every point)

    Declaration

    Objective-C

    extern NSArray<NSArray<NSValue *> *> *_Nonnull PSPDFConvertPDFLinesToViewLines(
        NSArray<NSArray<NSValue *> *> *_Nonnull lines,
        PSPDFPageInfo *_Nonnull pageInfo, CGRect viewBounds)

    Swift

    func PSPDFConvertPDFLinesToViewLines(_ lines: [[NSValue]], _ pageInfo: PSPDFPageInfo, _ viewBounds: CGRect) -> [[NSValue]]
  • Localizes strings. Will first look up the string in the PSPDFKit.bundle

    Declaration

    Objective-C

    extern NSString *_Nonnull PSPDFLocalize(NSString *_Nullable stringToken)

    Swift

    func PSPDFLocalize(_ stringToken: String?) -> String
  • Localizes strings with a list of arguments to substitute into stringToken.

    Declaration

    Objective-C

    extern NSString *_Nonnull PSPDFLocalizeFormatted(NSString *_Nonnull stringToken,
                                                     ...)
  • Sets a custom dictionary that contains dictionaries with language locales. Will override localization found in the bundle, if a value is found. Falls back to en if localization key is not found in dictionary. Set on the main thread.

    Declaration

    Objective-C

    extern void PSPDFSetLocalizationDictionary(
        NSDictionary<NSString *, NSDictionary<NSString *, NSString *> *>
            *_Nullable localizationDict)

    Swift

    func PSPDFSetLocalizationDictionary(_ localizationDict: [String : [String : String]]?)
  • Register a custom block that handles translation. If this block is NULL or returns nil, the PSPDFKit.bundle + localizationDict will be used.

    Declaration

    Objective-C

    extern void PSPDFSetLocalizationBlock(
        NSString *_Nullable (^_Nonnull localizationBlock)(NSString *_Nullable))

    Swift

    func PSPDFSetLocalizationBlock(_ localizationBlock: @escaping (String?) -> String?)
  • Convert a view point to the normalized PDF coordinate space. bounds is from the view. (usually PSPDFPageView.bounds)

    Declaration

    Objective-C

    extern CGPoint PSPDFConvertViewPointToPDFPoint(CGPoint viewPoint,
                                                   PSPDFPageInfo *_Nonnull pageInfo,
                                                   CGRect viewBounds)

    Swift

    func PSPDFConvertViewPointToPDFPoint(_ viewPoint: CGPoint, _ pageInfo: PSPDFPageInfo, _ viewBounds: CGRect) -> CGPoint
  • Converts a point in a normalized PDF coordinate space to the view coordinate space.

    Declaration

    Objective-C

    extern CGPoint PSPDFConvertPDFPointToViewPoint(CGPoint pdfPoint,
                                                   PSPDFPageInfo *_Nonnull pageInfo,
                                                   CGRect viewBounds)

    Swift

    func PSPDFConvertPDFPointToViewPoint(_ pdfPoint: CGPoint, _ pageInfo: PSPDFPageInfo, _ viewBounds: CGRect) -> CGPoint
  • Converts a rectangle from a normalized PDF coordinate space to the view coordinate space.

    Note

    Important: This is not a general purpose conversion function from PDF page to UIKit coordinates! If the pdfRect has negative width or height, the results will be unexpected.

    Declaration

    Objective-C

    extern CGRect PSPDFConvertPDFRectToViewRect(CGRect pdfRect,
                                                PSPDFPageInfo *_Nonnull pageInfo,
                                                CGRect viewBounds)

    Swift

    func PSPDFConvertPDFRectToViewRect(_ pdfRect: CGRect, _ pageInfo: PSPDFPageInfo, _ viewBounds: CGRect) -> CGRect
  • Converts a rectangle in a view coordinate space to the normalized PDF coordinate space.

    Note

    Important: This is not a general purpose conversion function from UIKit to PDF page coordinates! If the viewRect has negative width or height, the results will be unexpected.

    Declaration

    Objective-C

    extern CGRect PSPDFConvertViewRectToPDFRect(CGRect viewRect,
                                                PSPDFPageInfo *_Nonnull pageInfo,
                                                CGRect viewBounds)

    Swift

    func PSPDFConvertViewRectToPDFRect(_ viewRect: CGRect, _ pageInfo: PSPDFPageInfo, _ viewBounds: CGRect) -> CGRect
  • Performs a block and groups all observed changes into one event, if the undo controller is available.

    Declaration

    Objective-C

    extern void
    PSPDFPerformBlockAsGroup(PSPDFUndoController *_Nullable undoController,
                             dispatch_block_t _Nonnull block,
                             NSString *_Nullable name)

    Swift

    func PSPDFPerformBlockAsGroup(_ undoController: PSPDFUndoController?, _ block: () -> Void, _ name: String?)
  • Performs a block and ignores all observed changes, if the undo controller is available.

    Declaration

    Objective-C

    extern void
    PSPDFPerformBlockWithoutUndo(PSPDFUndoController *_Nullable undoController,
                                 dispatch_block_t _Nonnull block)

    Swift

    func PSPDFPerformBlockWithoutUndo(_ undoController: PSPDFUndoController?, _ block: () -> Void)