PTFileAttachmentHandler


@interface PTFileAttachmentHandler : NSObject

The PTFileAttachmentHandler class handles file attachment annotations. It can be used to export file attachment annotations from a document.

  • Initializes a newly created PTFileAttachmentHandler instance.

    Declaration

    Objective-C

    - (nonnull instancetype)init;

    Swift

    init()

    Return Value

    an initialized PTFileAttachmentHandler instance

  • Exports the specified file attachment annotation from the given PDF document.

    Declaration

    Objective-C

    - (void)exportFileAttachment:(nonnull PTFileAttachment *)fileAttachment
                      fromPDFDoc:(nonnull PTPDFDoc *)doc;

    Swift

    func export(_ fileAttachment: PTFileAttachment, from doc: PTPDFDoc)

    Parameters

    fileAttachment

    the file attachment to be exported

    doc

    the PDF document containing the file attachment

  • Exports the file attachment annotation from the PDF document.

    Declaration

    Objective-C

    - (void)exportFileAttachment:(nonnull PTFileAttachment *)fileAttachment
                      fromPDFDoc:(nonnull PTPDFDoc *)pdfDoc
                      completion:(nonnull void (^)(NSURL *_Nullable,
                                                   NSError *_Nullable))completion;

    Swift

    func export(_ fileAttachment: PTFileAttachment, from pdfDoc: PTPDFDoc) async throws -> URL

    Parameters

    fileAttachment

    The file attachment annotation to be exported

    pdfDoc

    The PDF document containing the file attachment

    completion

    A block to be called when the file attachment has been exported. The URL of the exported file is provided when the operation is successful, otherwise an error is provided that details why the file attachment could not be exported. The block is called asynchronously on the main queue.

  • The delegate of the file attachment handler. The delegate must adopt the PTFileAttachmentHandlerDelegate protocol.

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) id<PTFileAttachmentHandlerDelegate> delegate;

    Swift

    weak var delegate: (any PTFileAttachmentHandlerDelegate)? { get set }
  • Returns the filename for the specified file attachment annotation in the given PDF document.

    Declaration

    Objective-C

    + (nullable NSString *)
        filenameForFileAttachment:(nonnull PTFileAttachment *)fileAttachment
                       inDocument:(nonnull PTPDFDoc *)pdfDoc
                        withError:(NSError *_Nullable *_Nullable)error;

    Swift

    class func filename(for fileAttachment: PTFileAttachment, inDocument pdfDoc: PTPDFDoc) throws -> String

    Parameters

    fileAttachment

    The file attachment for which to get the filename

    pdfDoc

    The PDF document containing the file attachment annotation

    error

    On input, a pointer to an error object. If an error occurs , this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

    Return Value

    the filename for the file attachment annotation, or nil if an error occurred