SBSDKUIPDFRenderer

@interface SBSDKUIPDFRenderer : NSObject

A class to render a SBSDKUIDocument into a PDF.

  • Renders the document into a PDF at the specified file url. Performs HOCR if needed. HOCR is the process of adding an invisible text layer on top of each PDF page, containing the text extracted by the optical character recognizer. A PDF with HOCR is searchable and the text can be selected and copy-pasted.

    Declaration

    Objective-C

    + (nullable NSError *)renderDocument:(nonnull SBSDKUIDocument *)document
                             withOptions:(nonnull SBSDKPDFRendererOptions *)options
                                  output:(nonnull NSURL *)pdfOutputURL;

    Swift

    class func renderDocument(_ document: SBSDKUIDocument, with options: SBSDKPDFRendererOptions, output pdfOutputURL: URL) -> Error?

    Parameters

    document

    The document to be rendered as a PDF document.

    options

    The options the PDF renderer uses to render the PDF.

    pdfOutputURL

    The file URL where the PDF document is saved at.

    Return Value

    An NSError if the operation failed, nil otherwise.

  • Asynchronously renders the document into a PDF at the specified file url. Performs HOCR if needed. HOCR is the process of adding an invisible text layer on top of each PDF page, containing the text extracted by the optical character recognizer. A PDF with HOCR is searchable and the text can be selected and copy-pasted.

    Declaration

    Objective-C

    + (nullable SBSDKProgress *)
        renderDocument:(nonnull SBSDKUIDocument *)document
           withOptions:(nonnull SBSDKPDFRendererOptions *)options
                output:(nonnull NSURL *)pdfOutputURL
            completion:(nonnull void (^)(BOOL, NSError *_Nullable))completion;

    Swift

    class func renderDocument(_ document: SBSDKUIDocument, with options: SBSDKPDFRendererOptions, output pdfOutputURL: URL, completion: @escaping (Bool, Error?) -> Void) -> SBSDKProgress?

    Parameters

    document

    The document to be rendered as a PDF document.

    options

    The options the PDF renderer uses to render the PDF.

    pdfOutputURL

    The file URL where the PDF document is saved at.

    completion

    The completion handler that is being called upon completion of the operation on the main thread.

    Return Value

    A SBSDKProgress object that can be used to observe the operations progress and to cancel the operation.