Other Functions

The following functions are available globally.

  • Converts an annotation type into the string representation. Swift: Annotation.Tool(annotationType)

    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)
  • 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)
  • 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)
  • Undocumented

    Declaration

    Objective-C

    PSPDF_EXPORT UIApplication *PSPDFSharedApplication(void) NS_SWIFT_NAME(SharedApplication())

    Swift

    func SharedApplication() -> 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
  • Returns the concatenated text content of an array of glyphs.

    Declaration

    Objective-C

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

    Swift

    func PSPDFStringFromGlyphs(_ glyphs: [Glyph]?) -> String
  • Returns the bounding box that tightly encloses all the glyphs in the given array. This will be CGRectZero if glyphs is empty.

    Declaration

    Objective-C

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

    Swift

    func PSPDFBoundingBoxFromGlyphs(_ glyphs: [Glyph]?) -> CGRect
  • Returns the combined frames of the glyphs separated by lines, and (by reference) the bounding box that tightly encloses all these frames.

    The return value is suitable to use as the rects property of a text markup annotation. If all the glyphs are on the same line, then the returned array will contain a single entry that is equal to the returned bounding box. If the glyphs span multiple lines, then the array will contain one rectangle for each line. For example, the following 11 glyphs would return an array of 3 rectangles:

    □□□■■■

    ■■■■■■

    ■■□□□□

    Some padding should be added to the bounding box returned by reference before setting it as the bounding box of a text markup annotation to ensure the rendering of the annotation is not clipped.

    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 the range of the glyphs in the text parser, assuming the glyphs are in ascending order of their indexOnPage.

    If glyphs is not sorted, this will return an incorrect result.

    PSPDFInvalidGlyphRange is returned if glyphs is an empty array, or if the last glyph has an indexOnPage that is prior to the first glyph.

    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. Will return nil if there is no entry.

    Declaration

    Objective-C

    extern NSString *_Nullable PSPDFLocalizeWithoutFallback(
        NSString *_Nullable stringToken)

    Swift

    func localizedStringWithoutFallback(_ 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
  • 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]