pdfGetFormFieldValue
Get the value of a form field.
char *pdfGetFormFieldValue(PDFFormFieldHandle field, int *length)
This function returns the value of a form field (whose handle was
obtained with
pdfGetFormField
). The nature of the value depends
on the field type.
A string is returned, and *length
is filled in with the
string length. The string will be zero-terminated, but it may contain
zero bytes, depending on the current text encoding (see
pdfSetTextEncoding
). The caller is responsible for freeing the
string (if non-NULL) with the pdfFreeMemory
function.
C:
PDFFormFieldHandle field;
char *type, *name, *value;
int nameLength, page, maxLength, valueLength;
double xMin, yMin, xMax, yMax;
for (i = 0; i < pdfGetNumFormFields(pdf); ++i) {
field = pdfGetFormField(pdf, i);
type = pdfGetFormFieldType(field);
name = pdfGetFormFieldName(field, &nameLength);
pdfGetFormFieldBBox(field, &page, &xMin, &yMin, &xMax, &yMax);
maxLength = pdfGetFormFieldMaxLength(field);
value = pdfGetFormFieldValue(field, &valueLength);
...
if (value) {
...
pdfFreeMemory(value);
}
pdfFreeMemory(name);
}