SBSDKPDFRenderer

@interface SBSDKPDFRenderer : NSObject

A class to render an ordered collection of images with or without performing HOCR. 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.

  • The rendering options.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nonnull) SBSDKPDFRendererOptions *options;

    Swift

    var options: SBSDKPDFRendererOptions { get }
  • Undocumented

    Declaration

    Objective-C

    - (instancetype _Nonnull)init NS_UNAVAILABLE;
  • Designated initializer. Creates a new instance of the PDF renderer and configures it according to the specified configuration.

    Declaration

    Objective-C

    - (instancetype _Nonnull)initWithOptions:
        (nonnull SBSDKPDFRendererOptions *)renderOptions;

    Swift

    init(options renderOptions: SBSDKPDFRendererOptions)

    Parameters

    renderOptions

    The PDF rendering options.

    Return Value

    A new instance of the PDF renderer.

  • Asynchronously renders the images at the specified indices from the image storage into a PDF file with the given page size, saves the PDF to the specified URL and calls the completion handler when finished. Each page is made up of one image.

    Declaration

    Objective-C

    - (nullable SBSDKProgress *)
        renderImageStorage:(nonnull id<SBSDKImageStoring>)imageStorage
                  indexSet:(nullable NSIndexSet *)indices
                    output:(nonnull NSURL *)pdfOutputURL
                completion:(nonnull void (^)(BOOL, NSError *_Nullable))completion;

    Swift

    func renderImageStorage(_ imageStorage: SBSDKImageStoring, indexSet indices: IndexSet?, output pdfOutputURL: URL, completion: @escaping (Bool, Error?) -> Void) -> SBSDKProgress?

    Parameters

    imageStorage

    The image store to take the images from.

    indices

    The indices of images in the image store you want to render into the PDF. Pass nil if all images must be rendered.

    pdfOutputURL

    The output file URL.

    completion

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

    Return Value

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

  • Asynchronously renders the images at the specified indices from the image storage into a PDF file with the given page size, saves the PDF to the specified URL and calls the completion handler when finished. Each page is made up of one image.

    Declaration

    Objective-C

    - (nullable SBSDKProgress *)
        renderImageStorage:(nonnull id<SBSDKImageStoring>)imageStorage
                  indexSet:(nullable NSIndexSet *)indices
                 encrypter:(nullable id<SBSDKStorageCrypting>)encrypter
                    output:(nonnull NSURL *)pdfOutputURL
                completion:(nonnull void (^)(BOOL, NSError *_Nullable))completion;

    Swift

    func renderImageStorage(_ imageStorage: SBSDKImageStoring, indexSet indices: IndexSet?, encrypter: SBSDKStorageCrypting?, output pdfOutputURL: URL, completion: @escaping (Bool, Error?) -> Void) -> SBSDKProgress?

    Parameters

    imageStorage

    The image store to take the images from.

    indices

    The indices of images in the image store you want to render into the PDF. Pass nil if all images must be rendered.

    encrypter

    The encrypter used to encrypt the PDF file. If nil, no encryption is used.

    pdfOutputURL

    The output file URL.

    completion

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

    Return Value

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

  • Synchronously renders the images at the specified indices from the image storage into a PDF file with the given page size and saves the PDF to the specified URL. Each page is made up of one image.

    Declaration

    Objective-C

    - (BOOL)renderImageStorage:(nonnull id<SBSDKImageStoring>)imageStorage
                      indexSet:(nullable NSIndexSet *)indices
                        output:(nonnull NSURL *)pdfOutputURL
                      progress:(nullable SBSDKProgress *)progress
                         error:(NSError *_Nullable *_Nullable)outError;

    Swift

    func renderImageStorage(_ imageStorage: SBSDKImageStoring, indexSet indices: IndexSet?, output pdfOutputURL: URL, progress: SBSDKProgress?) throws

    Parameters

    imageStorage

    The image store to take the images from.

    indices

    The indices of images in the image store you want to render into the PDF. Pass nil if all images must be rendered.

    pdfOutputURL

    The output file URL.

    outError

    The pointer to an NSError when the rendering fails.

    Return Value

    YES, if the operation has finished successfully, NO otherwise.

  • Synchronously renders the images at the specified indices from the image storage into a PDF file with the given page size and saves the PDF to the specified URL. Each page is made up of one image.

    Declaration

    Objective-C

    - (BOOL)renderImageStorage:(nonnull id<SBSDKImageStoring>)imageStorage
                      indexSet:(nullable NSIndexSet *)indices
                     encrypter:(nullable id<SBSDKStorageCrypting>)encrypter
                        output:(nonnull NSURL *)pdfOutputURL
                      progress:(nullable SBSDKProgress *)progress
                         error:(NSError *_Nullable *_Nullable)outError;

    Swift

    func renderImageStorage(_ imageStorage: SBSDKImageStoring, indexSet indices: IndexSet?, encrypter: SBSDKStorageCrypting?, output pdfOutputURL: URL, progress: SBSDKProgress?) throws

    Parameters

    imageStorage

    The image store to take the images from.

    indices

    The indices of images in the image store you want to render into the PDF. Pass nil if all images must be rendered.

    encrypter

    The encrypter used to encrypt the PDF file. If nil, no encryption is used.

    pdfOutputURL

    The output file URL.

    outError

    The pointer to an NSError when the rendering fails.

    Return Value

    YES, if the operation has finished successfully, NO otherwise.