PSPDFImageDocument


@interface PSPDFImageDocument : PSPDFDocument

A PSPDFDocument 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.

PSPDFImageDocument needs the Image Documents feature in your license to work.

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

  • Creates a new image document, and will use PSPDFImageSaveFlattenAndEmbed as the image save mode. See imageSaveMode for details.

    Warning

    If your license does not contain the Image Documents feature, this method will raise an exception.

    Declaration

    Objective-C

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

    Swift

    init(imageURL: URL)

    Parameters

    imageURL

    A local file URL of the image.

    Return Value

    A new image document instance.

  • The image URL, if initialized via initWithImageURL:.

    Declaration

    Objective-C

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

    Swift

    var imageURL: URL? { get }
  • Specifies what is written back to the original image URL when the receiver is saved. If this proeprty 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 (assign, readwrite, atomic) PSPDFImageSaveMode imageSaveMode;

    Swift

    var imageSaveMode: PSPDFImageSaveMode { 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 (assign, readwrite, nonatomic) CGFloat compressionQuality;

    Swift

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

    Declaration

    Objective-C

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

    Swift

    class var supportedContentTypes: Set<String> { get }
  • The image is loaded and coverted to PDF asynchronously. Use this call to wait until the process is complete.

    Declaration

    Objective-C

    - (void)waitUntilLoaded;

    Swift

    func waitUntilLoaded()