Skip to content
Guides

Delete Form Fields

Since the form fields class inherits from the annotation class, the way to delete form fields is the same as delete annotations.

The steps to delete form fields are as follows:

  1. Obtain the page object from CPDFDocument where you want to delete the form field.

  2. Delete the form field.

This example shows how to delete form fields:

swift
var document = CPDFDocument(url: URL(string: "filePath"))
let page = document?.page(at: 0)

let annotation = page?.annotations[0]
page?.removeAnnotation(annotation)
objective-c
CPDFDocument *document = [[CPDFDocument alloc] initWithURL:[NSURL fileURLWithPath:@"filePath"]];
CPDFPage *page = [document pageAtIndex:0];

CPDFAnnotation *annotation = [[page annotations] objectAtIndex:0];
[page removeAnnotation:annotation];