Other Functions

The following functions are available globally.

  • Converts an annotation type into the string representation.

    Declaration

    Objective-C

    extern PSPDFAnnotationString _Nullable PSPDFStringFromAnnotationType(
        PSPDFAnnotationType annotationType)
  • Converts the annotation type string representation to an annotation type.

    Declaration

    Objective-C

    extern PSPDFAnnotationType
        PSPDFAnnotationTypeFromString(PSPDFAnnotationString _Nullable string)
  • Localizes the annotation type / variant string. If you have an annotation object, use the localizedType property instead of this function.

    Declaration

    Objective-C

    extern NSString *_Nonnull PSPDFLocalizeAnnotationType(
        PSPDFAnnotationString _Nonnull type,
        PSPDFAnnotationVariantString _Nullable variant)
  • Deprecated

    Deprecated in PSPDFKit 9.3 for iOS. This functionality should not be needed and will be removed in a future update. PSPDFFileAnnotationProvider already takes care of registering the appropriate overrides when reading an external annotation file.

    Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT void PSPDFAnnotationRegisterOverrideClasses(NSKeyedUnarchiver *unarchiver, PSPDFDocument *document) PSPDF_DEPRECATED(9.3, 4.3, "This functionality should not be needed and will be removed in a future update. `PSPDFFileAnnotationProvider` already takes care of registering the appropriate overrides when reading an external annotation file.")

    Swift

    func PSPDFAnnotationRegisterOverrideClasses(_ unarchiver: NSKeyedUnarchiver, _ document: PSPDFDocument)
  • Simple helper that combines a state + variant into a new identifier. Can be used to set custom types in the PSPDFStyleManager.

    Declaration

    Objective-C

    extern PSPDFAnnotationStateVariantID _Nonnull PSPDFAnnotationStateVariantIDMake(
        PSPDFAnnotationString _Nonnull,
        PSPDFAnnotationVariantString _Nullable variant)
  • Returns the original annotation state from a string that previously has been generated by PSPDFAnnotationStateVariantIDMake.

    Declaration

    Objective-C

    extern PSPDFAnnotationString _Nonnull PSPDFAnnotationStateFromStateVariantIdentifier(
        PSPDFAnnotationStateVariantID _Nonnull)
  • Returns the original annotation state variant from a string that previously has been generated by PSPDFAnnotationStateVariantIDMake.

    Declaration

    Objective-C

    extern PSPDFAnnotationVariantString _Nullable PSPDFAnnotationVariantFromStateVariantIdentifier(
        PSPDFAnnotationStateVariantID _Nonnull)
  • Deprecated

    Deprecated in PSPDFKit 10.1 for iOS. Please implement your own orientation handling.

    Checks that the requested interface orientation is supported by both view controller and application.

    Note

    This function is deprecated. Please implement your own orientation handling.

    Declaration

    Objective-C

    extern UIInterfaceOrientation
    PSPDFSafePreferredInterfaceOrientation(UIInterfaceOrientation requested,
                                           UIInterfaceOrientationMask supported,
                                           UIWindow *_Nullable window)

    Swift

    func PSPDFSafePreferredInterfaceOrientation(_ requested: UIInterfaceOrientation, _ supported: UIInterfaceOrientationMask, _ window: UIWindow?) -> UIInterfaceOrientation

    Parameters

    requested

    The requested preferred interface orientation.

    supported

    Value from view controller’s supportedInterfaceOrientations.

    window

    Window which hosts the view controller.

    Return Value

    Requested orientation if it’s supported by both view controller and application, otherwise falls back to current orientation.

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

    Declaration

    Objective-C

    extern BOOL PSPDFConflictResolutionAvailableForDataProvider(
        id<PSPDFCoordinatedFileDataProviding> _Nonnull dataProvider)

    Swift

    func ConflictResolutionAvailable(forDataProvider dataProvider: CoordinatedFileDataProviding) -> Bool

    Parameters

    dataProvider

    The data provider to check.

    Return Value

    true if conflict resolution APIs are implemented and conflict resolution is currently possible. false in all other cases.

  • Returns true, if all values are different from NAN and +inf/-inf.

    Declaration

    Objective-C

    extern BOOL PSPDFDrawingPointIsFinite(PSPDFDrawingPoint point)

    Swift

    var isFinite: Bool { get }
  • Yes when the location and intensity values match.

    Declaration

    Objective-C

    extern BOOL PSPDFDrawingPointIsEqualToPoint(PSPDFDrawingPoint point,
                                                PSPDFDrawingPoint otherPoint)

    Swift

    func isEqual(_ otherPoint: DrawingPoint) -> Bool
  • Converts the point into a string representation.

    Declaration

    Objective-C

    extern NSString *_Nonnull PSPDFDrawingPointToString(PSPDFDrawingPoint point)

    Swift

    var debugDescription: String { get }
  • The reverse operation to PSPDFDrawingPointToString. Returns PSPDFDrawingPointNull is parsing fails.

    Declaration

    Objective-C

    extern PSPDFDrawingPoint PSPDFDrawingPointFromString(NSString *_Nonnull string)

    Swift

    /*not inherited*/ init(string: String)
  • Creates a new PSPDFDrawingPoint.

    Declaration

    Objective-C

    extern PSPDFDrawingPoint PSPDFDrawingPointMake(CGPoint location,
                                                   CGFloat intensity)
  • Creates a new PSPDFDrawingPoint from a CGPoint, using PSPDFDefaultIntensity.

    Declaration

    Objective-C

    extern PSPDFDrawingPoint PSPDFDrawingPointFromCGPoint(CGPoint location)

    Swift

    /*not inherited*/ init(cgPoint location: CGPoint)
  • Deprecated

    Deprecated in PSPDFKit 10.0 for iOS. Use PSPDFDrawingPointIsFinite instead.

    Deprecated. Use PSPDFDrawingPointIsFinite instead.

    Declaration

    Objective-C

    extern BOOL PSPDFDrawingPointIsValid(PSPDFDrawingPoint point)

    Swift

    var isValid: Bool { get }
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT UIApplication *PSPDFSharedApplication(void)

    Swift

    func PSPDFSharedApplication() -> UIApplication!
  • Searches the responder chain for the closest system bar (toolbar/navigation bar).

    Declaration

    Objective-C

    extern UIView<PSPDFSystemBar> *_Nullable PSPDFSystemBarForResponder(
        UIResponder *_Nonnull responder)

    Swift

    func PSPDFSystemBarForResponder(_ responder: UIResponder) -> (UIView & SystemBar)?
  • Returns a string from PSPDFGalleryItemContentState.

    Declaration

    Objective-C

    extern NSString *_Nonnull NSStringFromPSPDFGalleryItemContentState(
        PSPDFGalleryItemContentState state)

    Swift

    func NSStringFromPSPDFGalleryItemContentState(_ state: GalleryItem.ContentState) -> String
  • Converts an NSString into PSPDFGalleryVideoItemQuality.

    Declaration

    Objective-C

    extern PSPDFGalleryVideoItemQuality
    PSPDFGalleryVideoItemQualityFromString(NSString *_Nonnull string)

    Swift

    func PSPDFGalleryVideoItemQualityFromString(_ string: String) -> GalleryVideoItem.Quality
  • Converts an NSString into PSPDFGalleryVideoItemCoverMode.

    Declaration

    Objective-C

    extern PSPDFGalleryVideoItemCoverMode
    PSPDFGalleryVideoItemCoverModeFromString(NSString *_Nonnull string)

    Swift

    func PSPDFGalleryVideoItemCoverModeFromString(_ string: String) -> GalleryVideoItem.CoverMode
  • Converts an array of glyphs to a string.

    Declaration

    Objective-C

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

    Swift

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

    Declaration

    Objective-C

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

    Swift

    func PSPDFBoundingBoxFromGlyphs(_ glyphs: [Glyph]?) -> 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: [Glyph]?, _ 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: [Glyph]) -> NSRange
  • Calculates the bounding box from lines.

    Declaration

    Objective-C

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

    Swift

    func BoundingBoxFromLines(_ 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 ConvertViewLines(pdfLines 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 viewBounds)

    Swift

    func ConvertViewLine(pdfLine line: [NSValue], pageInfo: PSPDFPageInfo, viewBounds: 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 ConvertPDFLines(viewLines 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 localizedString(_ 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 setLocalizationDictionary(_ localizationDict: [String : [String : String]]?)
  • Register a custom block that handles translation. If this block is NULL or returns nil, localizationDict followed by the PSPDFKit.bundle will be used.

    Declaration

    Objective-C

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

    Swift

    func setLocalizationClosure(_ 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: PDFPageInfo, _ 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: PDFPageInfo, _ 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: PDFPageInfo, _ 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: PDFPageInfo, _ 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

    class func performAsGroup(undoController: UndoController?, closure 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

    class func performWithoutUndo(undoController: UndoController?, closure block: () -> Void)
  • Helper method that will dig into popovers, navigation controllers, container view controllers or other controller view hierarchies and dig out the requested class if found.

    Declaration

    Objective-C

    extern id _Nullable PSPDFChildViewControllerForClass(
        UIViewController *_Nullable controller, Class _Nonnull controllerClass)

    Swift

    func PSPDFChildViewControllerForClass(_ controller: UIViewController?, _ controllerClass: AnyClass) -> Any?
  • Convert view lines to PDF lines.

    Declaration

    Swift

    public func ConvertToPDFLines(viewLines: [[CGPoint]], pageInfo: PDFPageInfo, viewBounds: CGRect) -> [[DrawingPoint]]
  • Converts a single line of boxed CGPoint.

    Declaration

    Swift

    public func ConvertToPDFLine(viewLine: [CGPoint], pageInfo: PDFPageInfo, viewBounds: CGRect) -> [DrawingPoint]