Documentation
¶
Overview ¶
Package forms provides AcroForm support for generated Paper PDFs.
Index ¶
- Constants
- type AcroForm
- type Field
- func NewCheckbox(name string, rect [4]float64, pageIndex int, checked bool) *Field
- func NewDropdown(name string, rect [4]float64, pageIndex int, options []string) *Field
- func NewListBox(name string, rect [4]float64, pageIndex int, options []string) *Field
- func NewMultilineTextField(name string, rect [4]float64, pageIndex int) *Field
- func NewPasswordField(name string, rect [4]float64, pageIndex int) *Field
- func NewRadioGroup(name string, options []RadioOption) *Field
- func NewSignatureField(name string, rect [4]float64, pageIndex int) *Field
- func NewTextField(name string, rect [4]float64, pageIndex int) *Field
- type FieldFlags
- type FieldType
- type FormFiller
- func (ff *FormFiller) Bytes() []byte
- func (ff *FormFiller) FieldNames() ([]string, error)
- func (ff *FormFiller) Flatten() error
- func (ff *FormFiller) GetValue(fieldName string) (string, error)
- func (ff *FormFiller) SaveTo(path string) error
- func (ff *FormFiller) SetCheckbox(fieldName string, checked bool) error
- func (ff *FormFiller) SetValue(fieldName, value string) error
- type RadioOption
Constants ¶
const ( FieldText = entity.FieldText FieldCheckbox = entity.FieldCheckbox FieldRadio = entity.FieldRadio FieldDropdown = entity.FieldDropdown FieldListBox = entity.FieldListBox FieldPushButton = entity.FieldPushButton FieldSignature = entity.FieldSignature )
The kinds of form field a Field can be.
const ( FlagReadOnly = entity.FlagReadOnly FlagRequired = entity.FlagRequired FlagNoExport = entity.FlagNoExport FlagMultiline = entity.FlagMultiline FlagPassword = entity.FlagPassword FlagFileSelect = entity.FlagFileSelect FlagDoNotSpellCheck = entity.FlagDoNotSpellCheck FlagDoNotScroll = entity.FlagDoNotScroll FlagComb = entity.FlagComb FlagRichText = entity.FlagRichText FlagCombo = entity.FlagCombo FlagEdit = entity.FlagEdit FlagSort = entity.FlagSort FlagMultiSelect = entity.FlagMultiSelect FlagNoToggleToOff = entity.FlagNoToggleToOff FlagRadioFlag = entity.FlagRadioFlag FlagPushButtonFlag = entity.FlagPushButtonFlag )
Field flags, grouped by the field kind they apply to: any field, text fields, choice fields, then button fields. Combine them with bitwise OR.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
Field is a single form field.
func NewCheckbox ¶
NewCheckbox creates a checkbox, initially ticked when checked is true.
func NewDropdown ¶
NewDropdown creates a combo box that shows one option at a time.
func NewListBox ¶
NewListBox creates a scrollable list showing several options at once.
func NewMultilineTextField ¶
NewMultilineTextField creates a text area that wraps across several lines.
func NewPasswordField ¶
NewPasswordField creates a text input that masks what is typed into it.
func NewRadioGroup ¶
func NewRadioGroup(name string, options []RadioOption) *Field
NewRadioGroup creates a set of radio buttons that share one name, so only one option can be selected. Each option carries its own page and box.
func NewSignatureField ¶
NewSignatureField creates an empty signature field for a reader to sign.
type FieldFlags ¶
type FieldFlags = entity.FieldFlags
FieldFlags is the set of behaviour flags on a field.
type FormFiller ¶
type FormFiller struct {
// contains filtered or unexported fields
}
FormFiller reads AcroForm fields from an existing PDF and writes filled or flattened PDF bytes.
func NewFormFiller ¶
func NewFormFiller(r *reader.PdfReader) *FormFiller
NewFormFiller creates a filler from a parsed PDF.
func (*FormFiller) Bytes ¶
func (ff *FormFiller) Bytes() []byte
Bytes returns the current PDF bytes after any appended form updates.
func (*FormFiller) FieldNames ¶
func (ff *FormFiller) FieldNames() ([]string, error)
FieldNames returns form field names in object order.
func (*FormFiller) Flatten ¶
func (ff *FormFiller) Flatten() error
Flatten renders supported AcroForm field values into page content and rewrites the PDF without active AcroForm/widget objects.
func (*FormFiller) GetValue ¶
func (ff *FormFiller) GetValue(fieldName string) (string, error)
GetValue returns the current value of fieldName.
func (*FormFiller) SaveTo ¶
func (ff *FormFiller) SaveTo(path string) error
SaveTo writes the current PDF bytes to path.
func (*FormFiller) SetCheckbox ¶
func (ff *FormFiller) SetCheckbox(fieldName string, checked bool) error
SetCheckbox sets a checkbox field's /V and /AS values.
func (*FormFiller) SetValue ¶
func (ff *FormFiller) SetValue(fieldName, value string) error
SetValue sets a text or choice field value by appending a replacement field object.
type RadioOption ¶
type RadioOption = entity.RadioOption
RadioOption is one button in a radio group, with its own page and box.