Click or drag to resize

HTML Forms to PDF Form Fields

With CreateFormFields set, the HTML form controls of the page become fillable PDF form fields at the same place: text boxes (inputs, password boxes, text areas), check boxes, radio button groups, drop-down lists and list boxes. The page's own borders and styling stay visible around the fields.

Converting a form
using ExpertPdf.Anywhere.HtmlToPdf;

string html = "<form><label>Name <input name='name'></label>" +
    "<label><input type='checkbox' name='agree'> I agree</label></form>";

PdfConverter converter = new PdfConverter();
// converter.LicenseKey = "your license key";
converter.CreateFormFields = true;
converter.SavePdfFromHtmlStringToFile(html, "form.pdf");
How the fields are made
  • A field is named after the control's name or id, and gets the control's value, checked state, options and selection, maximum length and read-only state. The label of the control becomes the field's description (its tooltip).

  • Radio buttons with the same name in a form become one radio button group.

  • The option needs JavaScript, which is enabled by default.

  • The fields work in PDF/A documents, and in tagged (PDF/UA) documents they are part of the logical structure, read where the control stood.

  • HtmlToPdfElement has the same option, for a form added to a page of a document.

To fill the fields of an existing PDF document from code, see Form Filling.

See Also

Other Resources

Form Filling
Tagged PDF