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
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
PSPDFFormElement
s 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 linkedPSPDFFormElements
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
PSPDFFormField
s to be removed.Return Value
YES if the form elements were removed, NO otherwise.
-
Given a list of
formFields
, resets the form fields from theAcroForms
structure inside the PDF.If the
includeExclude
flag is set to YES, resets all form fields except those in theformFields
list. If theincludeExclude
flag is set to NO, resets all form fields in theformFields
list.Note
If theformFields
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
PSPDFFormField
s 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 theformFields
list. SeePSPDFResetFormActionFlag
documentation.Return Value
YES if the form fields were reset, NO otherwise.