SBSDKPDFPagesExtractor

@interface SBSDKPDFPagesExtractor : NSObject

Class used to extract pages from a PDF file and returns them in various ways. Functions of this class are running in the same thread that they are called from, so it is up to you to control the concurrency. It is recommended to use background queues in most cases. Currently the flattening of the PDF document is user’s responsibility. So if the document will have unflattened annotations (except signs), they will not be exported.

  • Extracts pages from a PDF, converts them to JPEGs and writes them to a specified URL. Runs in the same thread that it is called from. No encryption is used here. The compression is set to 0.9. Media box scale value is 2

    Declaration

    Objective-C

    - (nonnull NSArray<NSURL *> *)imageURLsFromPDF:(nonnull NSURL *)pdfURL
                                   outputDirectory:(nonnull NSURL *)outputURL;

    Swift

    func imageURLs(fromPDF pdfURL: URL, outputDirectory outputURL: URL) -> [URL]

    Parameters

    pdfURL

    The URL of the PDF file.

    outputURL

    The output folder where images will be stored. Must be an existing folder.

    Return Value

    An array of URLs with extracted pages as JPEG files. The array will be empty if something is wrong.

  • Extracts pages from a PDF, converts them to JPEGs and writes them to a specified URL. Runs in the same thread that it is called from. No encryption is used here. Media box scale value is 2

    Declaration

    Objective-C

    - (nonnull NSArray<NSURL *> *)imageURLsFromPDF:(nonnull NSURL *)pdfURL
                                       compression:(float)compression
                                   outputDirectory:(nonnull NSURL *)outputURL;

    Swift

    func imageURLs(fromPDF pdfURL: URL, compression: Float, outputDirectory outputURL: URL) -> [URL]

    Parameters

    pdfURL

    The URL of the PDF file.

    compression

    Compression of the output image file. The range is from 0 to 1, where 1 - lossless conversion, 0 - maximum compression is used.

    outputURL

    The output folder where images will be stored. Must be an existing folder.

    Return Value

    An array of URLs with extracted pages as JPEG files. The array will be empty if something is wrong.

  • Extracts pages from a PDF, converts them to JPEGs and writes them to a specified URL. Runs in the same thread that it is called from.

    Declaration

    Objective-C

    - (nonnull NSArray<NSURL *> *)
        imageURLsFromPDF:(nonnull NSURL *)pdfURL
                 scaling:(CGFloat)scaling
             compression:(float)compression
               encrypter:(nullable id<SBSDKStorageCrypting>)encrypter
         outputDirectory:(nonnull NSURL *)outputURL;

    Swift

    func imageURLs(fromPDF pdfURL: URL, scaling: CGFloat, compression: Float, encrypter: SBSDKStorageCrypting?, outputDirectory outputURL: URL) -> [URL]

    Parameters

    pdfURL

    The URL of the PDF file.

    scaling

    Scaling applied to the PDF media box frame while extracting. Affects the output image quality. In most cases the recommended value is 2 and higher.

    compression

    Compression of the output image file. The range is from 0 to 1, where 1 - lossless conversion, 0 - maximum compression is used.

    encrypter

    The encrypter used to encrypt output image files. If nil, no encryption is used.

    outputURL

    The output folder where images will be stored. Must be an existing folder.

    Return Value

    An array of URLs with extracted pages as JPEG files. The array will be empty if something is wrong.

  • Extracts pages from PDF and converts them to an array of UIImages. Nothing is written to disk during this operation. Runs in the same thread, as it is called from. The scaling of the media box is set to 2.

    Declaration

    Objective-C

    - (nonnull NSArray<UIImage *> *)imagesFromPDF:(nonnull NSURL *)pdfURL;

    Swift

    func images(fromPDF pdfURL: URL) -> [UIImage]

    Parameters

    pdfURL

    The URL of the PDF file.

    Return Value

    An array of UIImages with extracted pages. The array will be empty if something is wrong.

  • Extracts pages from PDF and converts them to an array of UIImages. Nothing is written to disk during this operation. Runs in the same thread, as it is called from.

    Declaration

    Objective-C

    - (nonnull NSArray<UIImage *> *)imagesFromPDF:(nonnull NSURL *)pdfURL
                                          scaling:(CGFloat)scaling;

    Swift

    func images(fromPDF pdfURL: URL, scaling: CGFloat) -> [UIImage]

    Parameters

    pdfURL

    The URL of the PDF file.

    scaling

    Scaling applied to the PDF media box frame while extracting. Affects the output image quality. In most cases the recommended value is 2 and higher.

    Return Value

    An array of UIImages with extracted pages. The array will be empty if something is wrong.

  • Extracts pages from PDF and returns them as SBSDKUIDocument. Each page of the PDF will be a separate SBSDKUIPage. Runs in the same thread, as it is called from.

    Declaration

    Objective-C

    - (nonnull SBSDKUIDocument *)documentFromPDF:(nonnull NSURL *)pdfURL;

    Swift

    func document(fromPDF pdfURL: URL) -> SBSDKUIDocument

    Parameters

    pdfURL

    The URL of the PDF file.

    Return Value

    An array of UIImages with extracted pages. The array will be empty if something is wrong.