SBSDKPDFRenderer

@interface SBSDKPDFRenderer : NSObject

A static class that renders an ordered collection of images into a basic, none-searchable PDF. Very fast. It does not perform OCR.

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

    • SBSDKResultInfoImageStorageKey: the ordered collection of images as SBSDKImageStorage
    • SBSDKResultInfoDestinationFileURLKey: the file URL of the created PDF as NSURL

    Declaration

    Objective-C

    + (nullable SBSDKProgress *)
        renderImageStorage:(nonnull id<SBSDKImageStoring>)imageStorage
          copyImageStorage:(BOOL)copyStorage
                  indexSet:(nullable NSIndexSet *)indices
              withPageSize:(SBSDKPDFRendererPageSize)pageSize
                    output:(nonnull NSURL *)pdfOutputURL
         completionHandler:(nullable SBSDKCompletionHandler)completionHandler;

    Swift

    class func renderImageStorage(_ imageStorage: SBSDKImageStoring, copyImageStorage copyStorage: Bool, indexSet indices: IndexSet?, with pageSize: SBSDKPDFRendererPageSize, output pdfOutputURL: URL, completionHandler: SBSDKCompletionHandler? = nil) -> SBSDKProgress?

    Parameters

    imageStorage

    The image store to take the images from.

    copyStorage

    Whether the receiver should make a physical copy of the image storage for the operation or not. If set to NO, you must make sure that the image storage is not mutated while the operation is running. Setting YES makes a physical copy of the files in the storage, using up disk memory, but protecting it against mutation.

    indices

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

    pageSize

    The page size used to render an image into a page. See SBSDKPDFRendererPageSize.

    pdfOutputURL

    The output file URL.

    completionHandler

    The completionHandler that is being called upon completion of the operation. Called on main thread. The result info dictionary contains values for the following keys:

    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 none-searchable PDF with the given page size and saves the PDF to the specified URL. Each page is made up of one image.

    Declaration

    Objective-C

    + (nullable NSURL *)renderImageStorage:
                            (nonnull id<SBSDKImageStoring>)imageStorage
                                  indexSet:(nullable NSIndexSet *)indices
                              withPageSize:(SBSDKPDFRendererPageSize)pageSize
                                    output:(nonnull NSURL *)pdfOutputURL
                                     error:(NSError *_Nullable *_Nullable)outError;

    Swift

    class func renderImageStorage(_ imageStorage: SBSDKImageStoring, indexSet indices: IndexSet?, with pageSize: SBSDKPDFRendererPageSize, output pdfOutputURL: URL) throws -> URL

    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.

    pageSize

    The page size used to render an image into a page. See SBSDKPDFRendererPageSize.

    pdfOutputURL

    The output file URL.

    outError

    The pointer to an NSError when the rendering fails.

    Return Value

    The URL to the rendered PDF file.