forms

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package forms provides AcroForm support for generated Paper PDFs.

Index

Constants

View Source
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.

View Source
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 AcroForm

type AcroForm = entity.AcroForm

AcroForm is the set of fields belonging to a document.

func NewAcroForm

func NewAcroForm() *AcroForm

NewAcroForm creates an empty form to add fields to.

type Field

type Field = entity.Field

Field is a single form field.

func NewCheckbox

func NewCheckbox(name string, rect [4]float64, pageIndex int, checked bool) *Field

NewCheckbox creates a checkbox, initially ticked when checked is true.

func NewDropdown

func NewDropdown(name string, rect [4]float64, pageIndex int, options []string) *Field

NewDropdown creates a combo box that shows one option at a time.

func NewListBox

func NewListBox(name string, rect [4]float64, pageIndex int, options []string) *Field

NewListBox creates a scrollable list showing several options at once.

func NewMultilineTextField

func NewMultilineTextField(name string, rect [4]float64, pageIndex int) *Field

NewMultilineTextField creates a text area that wraps across several lines.

func NewPasswordField

func NewPasswordField(name string, rect [4]float64, pageIndex int) *Field

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

func NewSignatureField(name string, rect [4]float64, pageIndex int) *Field

NewSignatureField creates an empty signature field for a reader to sign.

func NewTextField

func NewTextField(name string, rect [4]float64, pageIndex int) *Field

NewTextField creates a single-line text input on the given page. rect is the field box as x1, y1, x2, y2.

type FieldFlags

type FieldFlags = entity.FieldFlags

FieldFlags is the set of behaviour flags on a field.

type FieldType

type FieldType = entity.FieldType

FieldType is the kind of a form 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL