iOS
ComPDFKit PDF SDK
Guides

Create & Edit Form Fields

 

Create form fields works the same as adding any other annotation, as can be seen in the guides for programmatically creating annotations.

 

NSURL *url = [NSURL fileURLWithPath:pdfPath];
CPDFDocument *document = [[[CPDFDocument alloc] initWithURL:url] autorelease];
CPDFPage *page = [document pageAtIndex:0];
​
NSMutableArray *items = [NSMutableArray array];
CPDFChoiceWidgetItem *item1 = [[[CPDFChoiceWidgetItem alloc] init] autorelease];
item1.value = @"1";
item1.string = @"a";
[items addObject:item1];
CPDFChoiceWidgetItem *item2 = [[[CPDFChoiceWidgetItem alloc] init] autorelease];
item2.value = @"2";
item2.string = @"b";
[items addObject:item2];
​
CPDFChoiceWidgetAnnotation *widget = [[[CPDFChoiceWidgetAnnotation alloc] initWithDocument:document listChoice:YES] autorelease];
widget.items = items;
[page addAnnotation:widget];