PSPDFDataContainerProvider

Objective-C


@interface PSPDFDataContainerProvider : NSObject <PSPDFDataProviding>

Swift

class DataContainerProvider : NSObject, DataProviding

An implementation of PSPDFDataProviding that operates on a single NSData.

This may be used to initialize Document with data.

Warning

You might want to set a custom UID otherwise the UID will be calculated from a part of the PDF contents, which might be the same if the files are similar.

Note

When using this data provider, PSPDFKit is unable to automatically save annotation changes back into the PDF. Keep in mind that iOS is an environment without virtual memory. Loading a large PDF will simply get your app killed by the iOS watchdog while you try to allocate more memory than is available.

If you use NSData because of encryption, look into PSPDFAESCryptoDataProvider or a custom implementation of PSPDFDataProviding instead for a way to dynamically decrypt the needed portions of the PDF.

  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Initializes a DataContainerProvider with the given data.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithData:(nonnull NSData *)data;

    Swift

    init(data: Data)

    Parameters

    data

    A blob containing the data to be held by the receiver.

    Return Value

    A new data provider.

  • An optional Progress object, indicating when the data backing the receiver is still being generated.

    If this property is not nil, the receiver is considered “in-flight” until the isFinished property of the progress object returns true: it acts as a promise for data that may become later.

    All reading and writing operations on an in-flight data container provider are going to fail, reporting PSPDFError.dataProviderIsInFlight where possible.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSProgress *progress;

    Swift

    var progress: Progress? { get }
  • Creates a new data container sink.

    If the options contains the append flag, and progress is completed, the data sink will contain all of data. Otherwise, the object returned will start with an empty buffer.

    Note

    This call never fails.

    Declaration

    Objective-C

    - (nullable id<PSPDFDataSink>)
        createDataSinkWithOptions:(PSPDFDataSinkOptions)options
                            error:(NSError *_Nullable *_Nullable)error;

    Swift

    func createDataSink(options: DataSinkOptions = []) throws -> DataSink
  • Replaces the receiver’s data with the data written to replacementDataSink.

    This method fails if the receiver is in-flight, meaning it has a progress object whose isFinished property returns false

    Warning

    This method raises an exception if replacementDataSink is not an instance of DataContainerSink, or if replacementDataSink.isFinished is false.

    Declaration

    Objective-C

    - (BOOL)replaceContentsWithDataSink:
                (nonnull id<PSPDFDataSink>)replacementDataSink
                                  error:(NSError *_Nullable *_Nullable)error;

    Swift

    func replaceContents(with replacementDataSink: DataSink) throws
  • Clears the the receiver’s data.

    Note

    This method never fails.

    Declaration

    Objective-C

    - (BOOL)deleteDataWithError:(NSError *_Nullable *_Nullable)error;

    Swift

    func deleteData() throws