form

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportForm

func ExportForm(xRefTable *model.XRefTable, source string, w io.Writer) (bool, error)

ExportForm extracts form data originating from source from xRefTable and writes a JSON representation to w.

func FieldMap

func FieldMap(fieldNames, formRecord []string) (map[string]CSVFieldAttributes, map[string]*Page, error)

FieldMap returns structures needed to fill a form via CSV.

func FillDetails

func FillDetails(form *Form, fieldMap map[string]CSVFieldAttributes) func(id, name string, fieldType FieldType, format DataFormat) ([]string, bool, bool)

FillDetails returns a closure that returns new form data provided by CSV or JSON.

func FillForm

func FillForm(
	ctx *model.Context,
	fillDetails func(id, name string, fieldType FieldType, format DataFormat) ([]string, bool, bool),
	imgs map[string]*Page,
	format DataFormat) (bool, []*model.Page, error)

FillForm populates form fields as provided by fillDetails and also supports virtual image fields.

func ListFormFields

func ListFormFields(ctx *model.Context) ([]string, error)

ListFormFields returns a list of all form fields present in xRefTable.

func LockFormFields

func LockFormFields(ctx *model.Context, fieldIDsOrNames []string) (bool, error)

LockFormFields turns all form fields contained in fieldIDsOrNames into read-only.

func RemoveFormFields

func RemoveFormFields(ctx *model.Context, fieldIDsOrNames []string) (bool, error)

RemoveFormFields deletes all form fields with given ID or name from the form represented by xRefTable.

func ResetFormFields

func ResetFormFields(ctx *model.Context, fieldIDsOrNames []string) (bool, error)

ResetFormFields clears or resets all form fields contained in fieldIDsOrNames to its default.

func UnlockFormFields

func UnlockFormFields(ctx *model.Context, fieldIDsOrNames []string) (bool, error)

UnlockFields turns all form fields contained in fieldIDsOrNames writeable.

Types

type CSVFieldAttributes

type CSVFieldAttributes struct {
	Values []string
	Lock   bool
}

CSVFieldAttributes represent the value(s) and the lock state for a field.

type CheckBox

type CheckBox struct {
	Pages   []int  `json:"pages"`
	ID      string `json:"id"`
	Name    string `json:"name,omitempty"`
	Default bool   `json:"default"`
	Value   bool   `json:"value"`
	Locked  bool   `json:"locked"`
}

RadioButtonGroup represents an Acroform checkbox.

type ComboBox

type ComboBox struct {
	Pages    []int    `json:"pages"`
	ID       string   `json:"id"`
	Name     string   `json:"name,omitempty"`
	Editable bool     `json:"editable"`
	Options  []string `json:"options"`
	Default  string   `json:"default,omitempty"`
	Value    string   `json:"value"`
	Locked   bool     `json:"locked"`
}

ListBox represents an Acroform combobox.

type DataFormat

type DataFormat int
const (
	CSV DataFormat = iota
	JSON
)

type DateField

type DateField struct {
	Pages   []int  `json:"pages"`
	ID      string `json:"id"`
	Name    string `json:"name,omitempty"`
	Format  string `json:"format"`
	Default string `json:"default,omitempty"`
	Value   string `json:"value"`
	Locked  bool   `json:"locked"`
}

DateField represents an Acroform date field.

type Field

type Field struct {
	// contains filtered or unexported fields
}

Field represents a form field for s particular page number.

type FieldMeta

type FieldMeta struct {
	// contains filtered or unexported fields
}

type FieldType

type FieldType int

FieldType represents a form field type.

const (
	FTText FieldType = iota
	FTDate
	FTCheckBox
	FTComboBox
	FTListBox
	FTRadioButtonGroup
)

type Form

type Form struct {
	TextFields        []*TextField        `json:"textfield,omitempty"`
	DateFields        []*DateField        `json:"datefield,omitempty"`
	CheckBoxes        []*CheckBox         `json:"checkbox,omitempty"`
	RadioButtonGroups []*RadioButtonGroup `json:"radiobuttongroup,omitempty"`
	ComboBoxes        []*ComboBox         `json:"combobox,omitempty"`
	ListBoxes         []*ListBox          `json:"listbox,omitempty"`
	Pages             map[string]*Page    `json:"pages,omitempty"`
}

Form represents a PDF form (aka. Acroform).

type FormGroup

type FormGroup struct {
	Header Header `json:"header"`
	Forms  []Form `json:"forms"`
}

FormGroup represents a JSON struct containing a sequence of form instances.

func ExportFormToStruct

func ExportFormToStruct(xRefTable *model.XRefTable, source string) (*FormGroup, bool, error)

ExportFormToStruct extracts form data originating from source from xRefTable.

type Header struct {
	Source   string   `json:"source"`
	Version  string   `json:"version"`
	Creation string   `json:"creation"`
	ID       []string `json:"id,omitempty"`
	Title    string   `json:"title,omitempty"`
	Author   string   `json:"author,omitempty"`
	Creator  string   `json:"creator,omitempty"`
	Producer string   `json:"producer,omitempty"`
	Subject  string   `json:"subject,omitempty"`
	Keywords string   `json:"keywords,omitempty"`
}

Header represents form meta data.

type ListBox

type ListBox struct {
	Pages    []int    `json:"pages"`
	ID       string   `json:"id"`
	Name     string   `json:"name,omitempty"`
	Multi    bool     `json:"multi"`
	Options  []string `json:"options"`
	Defaults []string `json:"defaults,omitempty"`
	Values   []string `json:"values,omitempty"`
	Locked   bool     `json:"locked"`
}

ListBox represents an Acroform listbox.

type Page

type Page struct {
	ImageBoxes []*primitives.ImageBox `json:"image,omitempty"`
}

Page is a container for page imageboxes.

type RadioButtonGroup

type RadioButtonGroup struct {
	Pages   []int    `json:"pages"`
	ID      string   `json:"id"`
	Name    string   `json:"name,omitempty"`
	Options []string `json:"options"`
	Default string   `json:"default,omitempty"`
	Value   string   `json:"value"`
	Locked  bool     `json:"locked"`
}

RadioButtonGroup represents an Acroform radio button group.

type TextField

type TextField struct {
	Pages     []int  `json:"pages"`
	ID        string `json:"id"`
	Name      string `json:"name,omitempty"`
	Default   string `json:"default,omitempty"`
	Value     string `json:"value"`
	Multiline bool   `json:"multiline"`
	Locked    bool   `json:"locked"`
}

TextField represents an Acroform text field.

Jump to

Keyboard shortcuts

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