Form Filling
Complete a PDF with form fields programmatically and save the PDF as a new completed PDF document. The DynamicPDF API makes completing forms programmatically a breeze.
Check out Getting Started and Task Roadmap if you are new to The DynamicPDF API.
You can also flatten the form fields in a PDF, remove form fields, and retain signature fields. Refer to the following documentation topic for more information on forms (pdf instructions - form fields).
The following examples illustrate.
Calling Endpoint Directly
Create a JSON instructions document and call it from the pdf endpoint directly.
- Define an input of type 
pdfcontaining the form to complete. - Create a 
formfieldsarray and add each field name and desired value to the array. 
{
  "author": "John Doe",
  "title": "My PDF From REST API",
  "inputs": [
    {
      "type": "pdf",
      "resourceName": "simple-form-fill.pdf"
    }
  ],
  "formFields": [
    {
      "name": "nameField",
      "value": "DynamicPDF"
    },
    {
      "name": "descriptionField",
      "value": "DynamicPDF CloudAPI. RealTime PDFs, Real FAST!"
    }
  ]
}
curl --location 'https://api.dpdf.io/v1.0/pdf'
--header 'Authorization: Bearer DP--api-key--'
--form 'Instructions=@C:/temp/solutions/forms/instructions.json'
--form 'Resource=@C:/temp/solutions/forms/simple-form-fill.pdf'

Calling Endpoint Using Client Library
Complete a form by calling the pdf programmatically using one of the DynamicPDF API's client libraries.
- C# (.NET)
 - Java
 - Node.js
 - PHP
 - Go
 - Python
 - Ruby
 
public static Pdf FormFieldsExample(String basePath) {
	Pdf pdf = new Pdf();
	pdf.AddPdf(new PdfResource(basePath + "simple-form-fill.pdf"));
	FormField formField = new FormField("nameField", "DynamicPdf");
	FormField formField2 = new FormField("descriptionField", "RealTime Pdf's. Real FAST!");
	pdf.FormFields.Add(formField);
	pdf.FormFields.Add(formField2);
	return pdf;
}
static async FormFieldsExample(apiKey, basePath) {
	var pdf = new Pdf();
    pdf.addPdf(new PdfResource(basePath + "simple-form-fill.pdf"));
    var formField = new FormField("nameField", "DynamicPdf");
    var formField2 = new FormField("descriptionField", "RealTime Pdf's. Real FAST!");
    pdf.formFields.push(formField);
    pdf.formFields.push(formField2);
    await this.ProcessAndSave(pdf, apiKey, basePath, "json-FormFieldsExample-output.pdf");
}
public static Pdf FormFieldsExample(String basePath) {
	Pdf pdf = new Pdf();
	pdf.addPdf(new PdfResource(basePath + "simple-form-fill.pdf"));
	FormField formField = new FormField("nameField", "DynamicPdf");
	FormField formField2 = new FormField("descriptionField", "RealTime Pdf's. Real FAST!");
	pdf.getFormFields().add(formField);
	pdf.getFormFields().add(formField2);
	return pdf;
}
public static function FormFieldsExample() {
	$pdf = new Pdf();
    $pdf->AddPdf("samples/shared/pdf/simple-form-fill.pdf");
    $formField = new FormField("nameField", "DynamicPDF");
    $formField2 = new FormField("descriptionField", "DynamicPDF CloudAPI. RealTime PDFs, Real FAST!");
    array_push($pdf->FormFields, $formField);
    array_push($pdf->FormFields, $formField2);
	return $pdf;
}
func acroFormExample(key string, baseUrl string) *endpoint.Pdf {
	pdfAcro := endpoint.NewPdf()
	pdfResource := resource.NewPdfResourceWithResourcePath(basePath +"simple-form-fill.pdf", "simple-form.pdf")
	pdfInput := input.NewPdfWithResource(pdfResource)
	pdfAcro.Inputs = append(pdfAcro.Inputs, pdfInput)
	field1 := endpoint.NewFormFieldWithValue("nameField", "DynamicPdf")
	pdfAcro.FormFields = append(pdfAcro.FormFields, *field1)
	field2 := endpoint.NewFormFieldWithValue("descriptionField", "RealRTime Pdf's. Real FAST!")
	pdfAcro.FormFields = append(pdfAcro.FormFields, *field2)
	pdfAcro.Endpoint.ApiKey = key
	pdfAcro.Endpoint.BaseUrl = baseUrl
	return pdfAcro
}
def ug_acro_form_example():
    pdf=Pdf()
    pdf.add_pdf("samples/users-guide-resources/simple-form-fill.pdf");
    formField = FormField("nameField", "DynamicPDF");
    formField2 = FormField("descriptionField", "DynamicPDF CloudAPI. RealTime PDFs, Real FAST!");
    pdf.form_fields.append(formField)
    pdf.form_fields.append(formField2)
    return pdf
  def self.form_fields_example(base_path)
    pdf = Pdf.new
    pdf.add_pdf(PdfResource.new("#{base_path}simple-form-fill.pdf"))
    pdf.form_fields << FormField.new('nameField', 'DynamicPDF')
    pdf.form_fields << FormField.new('descriptionField', 'DynamicPDF CloudAPI. RealTime PDFs, Real FAST!')
    pdf
  end
The pdf endpoint takes a JSON instructions document that provides instructions for creating, transforming, merging, and formatting inputs into a combined PDF. Refer to documentation on the instructions schema for information on how to use the pdf endpoint.