PSPDFFormParser

Objective-C


@interface PSPDFFormParser : NSObject <PSPDFOverridable>

Swift

class PDFFormParser : NSObject, Overridable

Parses PDF Forms (“AcroForms”). This will not create objects based on the (soon deprecated) XFA standard.

  • 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
  • Attached document provider.

    Declaration

    Objective-C

    @property (nonatomic, weak, readonly) PSPDFDocumentProvider *_Nullable documentProvider;

    Swift

    weak var documentProvider: PSPDFDocumentProvider? { get }
  • A collection of all forms in AcroForm. Lazily evaluated.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSArray<__kindof PSPDFFormElement *> *_Nonnull forms;

    Swift

    var forms: [PSPDFFormElement] { get }
  • A collection of all form fields in the AcroForm. Lazily evaluated.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly, nullable) NSArray<__kindof PSPDFFormField *> *formFields;

    Swift

    var formFields: [PSPDFFormField]? { get }
  • Return all “dirty” = unsaved form elements

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSArray<__kindof PSPDFFormElement *> *dirtyForms;

    Swift

    var dirtyForms: [PSPDFFormElement]? { get }
  • Finds a form element with its field name. Returns nil if not found.

    Declaration

    Objective-C

    - (nullable __kindof PSPDFFormElement *)findAnnotationWithFieldName:
        (nonnull NSString *)fieldName;

    Swift

    func findAnnotation(withFieldName fieldName: String) -> PSPDFFormElement?
  • Finds a form field with the given fully qualified field name.

    Declaration

    Objective-C

    - (nullable __kindof PSPDFFormField *)findFieldWithFullFieldName:
        (nonnull NSString *)fullFieldName;

    Swift

    func findField(withFullFieldName fullFieldName: String) -> PSPDFFormField?

    Parameters

    fullFieldName

    The fully qualified field name.

    Return Value

    The form field, if found. nil otherwise.

  • Removes the form elements from the AcroForms structure inside the PDF and also removes the visual representation (widget annotation) from the pages.

    Note

    The PSPDFFormField will also be removed if it doesn’t contain any PSPDFFormElement any more.

    Note

    Depending on the size of your document, this operation will be slow and should not be run on the main thread.

    Declaration

    Objective-C

    - (BOOL)removeFormElements:
                (nonnull NSArray<__kindof PSPDFFormElement *> *)formElements
                         error:(NSError *_Nullable *_Nullable)error;

    Swift

    func remove(_ formElements: [PSPDFFormElement]) throws

    Parameters

    formElements

    The PSPDFFormElements to be removed.

    Return Value

    YES if the form elements were removed, NO otherwise.

  • Removes the form fields from the AcroForms structure inside the PDF, removes all linked PSPDFFormElements and their visual representation (widget annotation) from the pages.

    Note

    Depending on the size of your document, this operation will be slow and should not be run on the main thread.

    Declaration

    Objective-C

    - (BOOL)removeFormFields:
                (nonnull NSArray<__kindof PSPDFFormField *> *)formFields
                       error:(NSError *_Nullable *_Nullable)error;

    Swift

    func removeFormFields(_ formFields: [PSPDFFormField]) throws

    Parameters

    formFields

    The PSPDFFormFields to be removed.

    Return Value

    YES if the form elements were removed, NO otherwise.

  • Given a list of formFields, resets the form fields from the AcroForms structure inside the PDF.

    If the includeExclude flag is set to YES, resets all form fields except those in the formFields list. If the includeExclude flag is set to NO, resets all form fields in the formFields list.

    Note

    If the formFields list is empty, resets all form fields in the PDF document.

    Declaration

    Objective-C

    - (BOOL)resetForm:(nonnull NSArray<PSPDFFormField *> *)formFields
            withFlags:(PSPDFResetFormActionFlag)resetFormActionFlags
                error:(NSError *_Nullable *_Nullable)error;

    Swift

    func resetForm(_ formFields: [PSPDFFormField], withFlags resetFormActionFlags: ResetFormAction.Flag) throws

    Parameters

    formFields

    The PSPDFFormFields to be reset.

    resetFormActionFlags

    Decides if the form fields that will be reset are those in the formFields list or every form field that is not in the formFields list. See PSPDFResetFormActionFlag documentation.

    Return Value

    YES if the form fields were reset, NO otherwise.