PSPDFImageDocument

Objective-C


@interface PSPDFImageDocument : PSPDFDocument

Swift

class ImageDocument : Document

A Document subclass that can be used to display and annotate image files. Can handle JPEG and PNG images.

Note

Any transparency on PNG images will be lost after saving.

Saving changes flattens any annotations into the image and writes it back to the original file. Creating a new document will then reflect the new image with flattened changes. Keep the image document in memory to preserve the ability to edit added annotations.

See https://pspdfkit.com/guides/ios/current/annotations/annotate-images/ for more information.

Note

PSPDFImageDocument requires the Image Documents feature to be enabled for your license to work.
  • Creates a new image document using PSPDFImageSaveModeFlattenAndEmbed.

    Note

    This method requires the Image Documents feature to be enabled for your license.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithImageDataProvider:
        (nonnull id<PSPDFDataProviding>)imageDataProvider;

    Swift

    init(imageDataProvider: DataProviding)

    Parameters

    imageDataProvider

    A data provider that supplies the image content.

    Return Value

    A new image document instance.

  • Creates a new image document using PSPDFImageSaveModeFlattenAndEmbed.

    Note

    This method requires the Image Documents feature to be enabled for your license.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithImageURL:(nonnull NSURL *)imageURL;

    Swift

    init(imageURL: URL)

    Parameters

    imageURL

    A file URL of the image.

    Return Value

    A new image document instance.

  • The data provider that the image document was initialized with.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) id<PSPDFDataProviding> imageDataProvider;

    Swift

    var imageDataProvider: DataProviding? { get }
  • The image file URL, if the image document was initialized via initWithImageURL: or with a file data provider.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSURL *imageURL;

    Swift

    var imageURL: URL? { get }
  • The image is loaded and converted to PDF asynchronously. Use this call to wait until the process is complete.

    Note

    This will block the current thread.

    Declaration

    Objective-C

    - (void)waitUntilLoaded;

    Swift

    func waitUntilLoaded()
  • Specifies what is written back to the original image URL when the receiver is saved. If this property is PSPDFImageSaveModeFlattenAndEmbed, then this allows for changes made to the image to be saved as metadata in the original file. If the same file is reopened with PSPDFImageDocument, all previous changes made will remain editable. This will increase the amount of space the image takes on disk.

    If this property is PSPDFImageSaveModeFlatten, the changes are simply written to the image, and will not be editable when reopened with PSPDFImageDocument.

    Note

    For changes to this property to be effective, they must be made prior to calling -[PSPDFImageDocument save:].

    Declaration

    Objective-C

    @property PSPDFImageSaveMode imageSaveMode;

    Swift

    var imageSaveMode: ImageDocument.SaveMode { get set }
  • The compression quality for writing JPEG images.

    Bound to a value between 0.0 (most compression) and 1.0 (least compression). Defaults to 1.0 - best image quality and largest image size.

    Note

    We recommend using a large compressionQuality value to prevent quality degradation during subsequent editing sessions.

    Declaration

    Objective-C

    @property (nonatomic) CGFloat compressionQuality;

    Swift

    var compressionQuality: CGFloat { get set }
  • A set containing UTI types supported by the image document class.

    Declaration

    Objective-C

    @property (class, nonatomic, readonly) NSSet<NSString *> *_Nonnull supportedContentTypes;

    Swift

    class var supportedContentTypes: Set<String> { get }
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    - (instancetype)init PSPDF_NOT_DESIGNATED_INITIALIZER_ATTRIBUTE;
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    - (nonnull instancetype)initWithURL:(nonnull NSURL *)URL;
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    - (nonnull instancetype)initWithDataProviders:
                                (nonnull NSArray<id<PSPDFDataProviding>> *)
                                    dataProviders
                        loadCheckpointIfAvailable:(BOOL)loadCheckpoint;
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    - (nonnull instancetype)initWithDataProviders:
        (nonnull NSArray<id<PSPDFDataProviding>> *)dataProviders;