How to fill and flatten PDF forms ?
Interactive PDF forms are collections of fields for gathering information interactively from the user. The form fields are stored separately from the visual content. In simple terms, each form field typically has a name, type and a value. Each field also typically also has a visual appearance. If it does not have an appearance, it can be generated by PDF.
Common Use Cases
UniPDF has a comprehensive support for PDF forms. Key use cases:
- Create new forms on top of documents. For example create a PDF from Word with blanks and then add an interactive form on top of it.
- pdf_form_add.go shows how to add create and apply a new form to an existing PDF.
- Get list of fields from a form and their values. Relevant examples:
- pdf_form_get_field_data.go shows how to get form field data for a specific field from a PDF file.
- fdf_fields_info.go outputs information about fields in a Field Data Format (FDF) file.
- pdf_form_list_fields.go lists form fields in a PDF.
- Fill in a form with values.
- pdf_form_fill_json.go supports exporting form data as JSON as well filling form and outputting a flattened PDF.
- pdf_form_fill_custom_font.go illustrates on how to use a custom font (simple TTF font and CJK font) when filling and flattening forms.
- Flatten a form such that the content becomes part of the document and not editable.
- pdf_form_fill_json.go supports exporting form data as JSON as well filling form and outputting a flattened PDF.
- pdf_form_fill_fdf_merge.go illustates FDF merging - merging FDF form data (values) with a template PDF, producing a flattened output PDF (with appearances streams generated).