Documentation ¶
Index ¶
- Variables
- func CalcCheckBoxASNames(d types.Dict) (types.Name, types.Name)
- func EnsureComboBoxAP(ctx *model.Context, d types.Dict, v string, fonts map[string]types.IndirectRef) error
- func EnsureDateFieldAP(ctx *model.Context, d types.Dict, v string, fonts map[string]types.IndirectRef) error
- func EnsureListBoxAP(ctx *model.Context, d types.Dict, opts []string, ind types.Array, ...) error
- func EnsureTextFieldAP(ctx *model.Context, d types.Dict, v string, multiLine bool, ...) error
- func FontIndRef(fName string, ctx *model.Context, fonts map[string]types.IndirectRef) (*types.IndirectRef, error)
- func FormFontNameAndLangForID(xRefTable *model.XRefTable, indRef types.IndirectRef) (string, string, error)
- func FormFontResDict(xRefTable *model.XRefTable) (types.Dict, error)
- func NewForm(xRefTable *model.XRefTable, bb []byte, fontID string, ...) (*types.IndirectRef, error)
- func UpdateForm(xRefTable *model.XRefTable, bb []byte, indRef *types.IndirectRef) error
- type AP
- type Bar
- type Border
- type Buttons
- type CheckBox
- type ComboBox
- type Content
- type DateField
- type DateFormat
- type Divider
- type FieldFlags
- type FieldGroup
- type FormFont
- type Guide
- type HorizontalBand
- type ImageBox
- type ImageData
- type ListBox
- type Margin
- type PDF
- type PDFPage
- type Padding
- type RadioButtonGroup
- type Regions
- type SimpleBox
- type Table
- type TableHeader
- type TextBox
- type TextField
- type TextFieldLabel
Constants ¶
This section is empty.
Variables ¶
var ISO639Codes = []string{}/* 183 elements not displayed */
ISO-639 country codes See https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
Functions ¶
func EnsureComboBoxAP ¶
func EnsureDateFieldAP ¶
func EnsureListBoxAP ¶
func EnsureTextFieldAP ¶
func FontIndRef ¶
func FontIndRef(fName string, ctx *model.Context, fonts map[string]types.IndirectRef) (*types.IndirectRef, error)
func FormFontResDict ¶
FormFontResDict returns form dict's font resource dict.
func UpdateForm ¶
Types ¶
type Bar ¶
type Bar struct {
X, Y float64 // either or determines orientation.
Width int
Color string `json:"col"`
Style string
Hide bool
// contains filtered or unexported fields
}
Bar represents a horizontal or vertical bar used by content.
type Buttons ¶
type Buttons struct { Values []string Label *TextFieldLabel Gap int // horizontal space between radio button and its value // contains filtered or unexported fields }
type CheckBox ¶
type CheckBox struct { Label *TextFieldLabel ID string Tip string Value bool // checked state Default bool Position [2]float64 `json:"pos"` // x,y Width float64 Dx, Dy float64 Margin *Margin // applied to content box BackgroundColor string `json:"bgCol"` Tab int Locked bool Debug bool Hide bool // contains filtered or unexported fields }
CheckBox represents a form checkbox including a positioned label.
type ComboBox ¶
type ComboBox struct { Label *TextFieldLabel ID string Tip string Default string Value string Options []string Position [2]float64 `json:"pos"` Width float64 Dx, Dy float64 BoundingBox *types.Rectangle `json:"-"` Edit bool Font *FormFont Margin *Margin Border *Border BackgroundColor string `json:"bgCol"` BgCol *color.SimpleColor `json:"-"` Alignment string `json:"align"` // "Left", "Center", "Right" HorAlign types.HAlignment `json:"-"` RTL bool Tab int Locked bool Debug bool Hide bool // contains filtered or unexported fields }
ComboBox represents a specific choice form field including a positioned label.
func NewComboBox ¶
func NewComboBox( ctx *model.Context, d types.Dict, v string, fonts map[string]types.IndirectRef) (*ComboBox, *types.IndirectRef, error)
NewComboBox creates a new combobox for d.
type Content ¶
type Content struct { BackgroundColor string `json:"bgCol"` Fonts map[string]*FormFont // named fonts Margins map[string]*Margin // named margins Borders map[string]*Border // named borders Paddings map[string]*Padding // named paddings Margin *Margin // content margin Border *Border // content border Padding *Padding // content padding Regions *Regions Guides []*Guide // hor/vert guidelines for layout Bars []*Bar `json:"bar"` SimpleBoxes []*SimpleBox `json:"box"` SimpleBoxPool map[string]*SimpleBox `json:"boxes"` TextBoxes []*TextBox `json:"text"` TextBoxPool map[string]*TextBox `json:"texts"` ImageBoxes []*ImageBox `json:"image"` ImageBoxPool map[string]*ImageBox `json:"images"` Tables []*Table `json:"table"` TablePool map[string]*Table `json:"tables"` // Form elements TextFields []*TextField `json:"textfield"` // input text fields with optional label DateFields []*DateField `json:"datefield"` // input date fields with optional label CheckBoxes []*CheckBox `json:"checkbox"` // input checkboxes with optional label RadioButtonGroups []*RadioButtonGroup `json:"radiobuttongroup"` // input radiobutton groups with optional label ComboBoxes []*ComboBox `json:"combobox"` ListBoxes []*ListBox `json:"listbox"` FieldGroups []*FieldGroup `json:"fieldgroup"` // rectangular container holding form elements FieldGroupPool map[string]*FieldGroup `json:"fieldgroups"` // contains filtered or unexported fields }
Content represents page content.
func (*Content) BorderRect ¶
BorderRect returns the border rect for c.
type DateField ¶
type DateField struct { Label *TextFieldLabel ID string Tip string Value string Default string DateFormat string `json:"format"` Position [2]float64 `json:"pos"` // x,y Width float64 Dx, Dy float64 BoundingBox *types.Rectangle `json:"-"` Font *FormFont Margin *Margin // applied to content box Border *Border BackgroundColor string `json:"bgCol"` BgCol *color.SimpleColor `json:"-"` Alignment string `json:"align"` // "Left", "Center", "Right" HorAlign types.HAlignment `json:"-"` Tab int Locked bool Debug bool Hide bool // contains filtered or unexported fields }
DateField is a form field accepting date strings according to DateFormat including a positioned label.
func NewDateField ¶
func NewDateField( ctx *model.Context, d types.Dict, v string, fonts map[string]types.IndirectRef) (*DateField, *types.IndirectRef, error)
NewDateField returns a new date field for d.
type DateFormat ¶
DateFormat represents a supported date format. It consists of an internal and an external form.
func DateFormatForDate ¶
func DateFormatForDate(date string) (*DateFormat, error)
DateFormatForDate returns the date format for given date string.
func DateFormatForFmtExt ¶
func DateFormatForFmtExt(fmtExt string) (*DateFormat, error)
DateFormatForFmtInt returns the date format for an external format string.
func DateFormatForFmtInt ¶
func DateFormatForFmtInt(fmtInt string) (*DateFormat, error)
DateFormatForFmtInt returns the date format for an internal format string.
type Divider ¶
type Divider struct { Pos float64 `json:"at"` // fraction 0..1 Width int // 1..10 Color string `json:"col"` // contains filtered or unexported fields }
Divider is a positioned separator between two regions from p to q.
type FieldFlags ¶
type FieldFlags int
FieldFlags represents the PDF form field flags. See table 221 et.al.
const ( FieldReadOnly FieldFlags = 1 << iota FieldRequired FieldNoExport UnusedFlag4 UnusedFlag5 UnusedFlag6 UnusedFlag7 UnusedFlag8 UnusedFlag9 UnusedFlag10 UnusedFlag11 UnusedFlag12 FieldMultiline FieldPassword FieldNoToggleToOff FieldRadio FieldCombo FieldEdit FieldSort FieldFileSelect FieldMultiselect FieldDoNotSpellCheck FieldDoNotScroll FieldComb FieldRichTextAndRadiosInUnison FieldCommitOnSelChange )
type FieldGroup ¶
type FieldGroup struct { Name string Value string Border *Border Padding *Padding BackgroundColor string `json:"bgCol"` TextFields []*TextField `json:"textfield"` // text fields with optional label DateFields []*DateField `json:"datefield"` // date fields with optional label CheckBoxes []*CheckBox `json:"checkbox"` // checkboxes with optional label RadioButtonGroups []*RadioButtonGroup `json:"radiobuttongroup"` // radiobutton groups with optional label ComboBoxes []*ComboBox `json:"combobox"` // comboboxes with optional label ListBoxes []*ListBox `json:"listbox"` // listboxes with optional label Hide bool // contains filtered or unexported fields }
FieldGroup is a container for fields.
type FormFont ¶
type FormFont struct { Name string Lang string // ISO-639 Script string // ISO-15924 Size int Color string `json:"col"` // contains filtered or unexported fields }
func (*FormFont) SetCol ¶
func (f *FormFont) SetCol(c color.SimpleColor)
type Guide ¶
type Guide struct { Position [2]float64 `json:"pos"` // x,y // contains filtered or unexported fields }
Guide represents horizontal and vertical lines at (x,y) for layout purposes.
type HorizontalBand ¶
type HorizontalBand struct { Left string Center string Right string Height float64 Dx, Dy int BackgroundColor string `json:"bgCol"` Font *FormFont From int Thru int Border bool RTL bool // contains filtered or unexported fields }
HorizontalBand is a horizontal region used for header and footer.
type ImageBox ¶
type ImageBox struct { Name string Src string `json:"src"` // path of image file name Data *ImageData // TODO Implement Position [2]float64 `json:"pos"` // x,y Dx, Dy float64 Anchor string Width float64 Height float64 Margin *Margin Border *Border Padding *Padding BackgroundColor string `json:"bgCol"` Rotation float64 `json:"rot"` Url string Hide bool PageNr string `json:"-"` // contains filtered or unexported fields }
ImageBox is a rectangular region within content containing an image.
type ImageData ¶
type ImageData struct { Payload string // base64 encoded image data Format string // jpeg, png, webp, tiff, ccitt Width, Height int }
ImageData represents a more direct way for providing image data for form filling scenarios.
type ListBox ¶
type ListBox struct { Label *TextFieldLabel ID string Tip string Default string Defaults []string Value string Values []string Ind types.Array `json:"-"` Options []string Position [2]float64 `json:"pos"` Width float64 Height float64 Dx, Dy float64 BoundingBox *types.Rectangle `json:"-"` Multi bool `json:"multi"` Font *FormFont Margin *Margin Border *Border BackgroundColor string `json:"bgCol"` BgCol *color.SimpleColor `json:"-"` Alignment string `json:"align"` // "Left", "Center", "Right" HorAlign types.HAlignment `json:"-"` RTL bool Tab int Locked bool Debug bool Hide bool // contains filtered or unexported fields }
ListBox represents a specific choice form field including a positioned label.
type PDF ¶
type PDF struct { Paper string // default paper size Crop string // default crop box Origin string // origin of the coordinate system Guides bool // render guides for layouting ContentBox bool // render contentBox = cropBox - header - footer Debug bool // highlight element positions BackgroundColor string `json:"bgCol"` Fonts map[string]*FormFont // global fonts FormFonts map[string]*FormFont FieldIDs types.StringSet Fields types.Array InheritedDA string Header *HorizontalBand Pages map[string]*PDFPage Margin *Margin // the global margin named "margin" Border *Border // the global border named "border" Padding *Padding // the global padding named "padding" Margins map[string]*Margin // global named margins Borders map[string]*Border // global named borders Paddings map[string]*Padding // global named paddings SimpleBoxPool map[string]*SimpleBox `json:"boxes"` TextBoxPool map[string]*TextBox `json:"texts"` ImageBoxPool map[string]*ImageBox `json:"images"` TablePool map[string]*Table `json:"tables"` FieldGroupPool map[string]*FieldGroup `json:"fieldgroups"` Colors map[string]string DirNames map[string]string `json:"dirs"` FileNames map[string]string `json:"files"` TimestampFormat string `json:"timestamp"` DateFormat string `json:"dateFormat"` Conf *model.Configuration `json:"-"` XRefTable *model.XRefTable `json:"-"` Optimize *model.OptimizationContext `json:"-"` FontResIDs map[int]types.Dict `json:"-"` XObjectResIDs map[int]types.Dict `json:"-"` CheckBoxAPs map[float64]*AP `json:"-"` RadioBtnAPs map[float64]*AP `json:"-"` HasForm bool `json:"-"` OldFieldIDs types.StringSet `json:"-"` // contains filtered or unexported fields }
PDF is the central structure for PDF generation.
func (*PDF) DuplicateField ¶
func (*PDF) RenderPages ¶
RenderPages renders page content into model.Pages
type PDFPage ¶
type PDFPage struct { Paper string // page size Crop string // page crop box BackgroundColor string `json:"bgCol"` Fonts map[string]*FormFont // default fonts DA types.Object Guides []*Guide // hor/vert guidelines for layout Margin *Margin // page margin Border *Border // page border Padding *Padding // page padding Margins map[string]*Margin // page scoped named margins Borders map[string]*Border // page scoped named borders Paddings map[string]*Padding // page scoped named paddings SimpleBoxPool map[string]*SimpleBox `json:"boxes"` TextBoxPool map[string]*TextBox `json:"texts"` ImageBoxPool map[string]*ImageBox `json:"images"` TablePool map[string]*Table `json:"tables"` FieldGroupPool map[string]*FieldGroup `json:"fieldgroups"` FileNames map[string]string `json:"files"` Tabs types.IntSet `json:"-"` Content *Content // contains filtered or unexported fields }
PDFPage represents a PDF page with content for generation.
type RadioButtonGroup ¶
type RadioButtonGroup struct { Label *TextFieldLabel ID string Tip string Value string // checked button Default string Position [2]float64 `json:"pos"` // x,y Width float64 Orientation string Dx, Dy float64 Margin *Margin // applied to content box BackgroundColor string `json:"bgCol"` Buttons *Buttons RTL bool Tab int Locked bool Debug bool Hide bool // contains filtered or unexported fields }
RadioButtonGroup represents a set of radio buttons including positioned labels.
func (*RadioButtonGroup) Rtl ¶
func (rbg *RadioButtonGroup) Rtl() bool
type SimpleBox ¶
type SimpleBox struct { Name string Position [2]float64 `json:"pos"` // x,y Dx, Dy float64 Anchor string Width float64 Height float64 Margin *Margin Border *Border FillColor string `json:"fillCol"` Rotation float64 `json:"rot"` Hide bool // contains filtered or unexported fields }
SimpleBox is a positioned rectangular region within content.
type Table ¶
type Table struct { Name string Values [][]string Position [2]float64 `json:"pos"` // x,y Dx, Dy float64 Anchor string Width float64 // if < 1 then fraction of content width Rows, Cols int ColWidths []int // optional column width percentages ColAnchors []string ColPaddings []*Padding LineHeight int `json:"lheight"` Font *FormFont Margin *Margin Border *Border Padding *Padding BackgroundColor string `json:"bgCol"` OddColor string `json:"oddCol"` EvenColor string `json:"evenCol"` RTL bool Rotation float64 `json:"rot"` Grid bool Hide bool Header *TableHeader // contains filtered or unexported fields }
Table represents a positioned fillable data grid including a header row.
type TableHeader ¶
type TextBox ¶
type TextBox struct { Name string Value string // text, content Position [2]float64 `json:"pos"` // x,y Dx, Dy float64 Anchor string Width float64 Font *FormFont Margin *Margin // applied to content box Border *Border Padding *Padding // applied to TextDescriptor marginx BackgroundColor string `json:"bgCol"` Alignment string `json:"align"` // "Left", "Center", "Right" RTL bool Rotation float64 `json:"rot"` Hide bool // contains filtered or unexported fields }
TextBox represents a form text input field including a positioned label.
type TextField ¶
type TextField struct { Label *TextFieldLabel ID string Tip string Value string Default string Position [2]float64 `json:"pos"` // x,y Width float64 Height float64 Dx, Dy float64 BoundingBox *types.Rectangle `json:"-"` Multiline bool Font *FormFont Margin *Margin // applied to content box Border *Border BackgroundColor string `json:"bgCol"` BgCol *color.SimpleColor `json:"-"` Alignment string `json:"align"` // "Left", "Center", "Right" HorAlign types.HAlignment `json:"-"` RTL bool Tab int Locked bool Debug bool Hide bool // contains filtered or unexported fields }
func NewTextField ¶
func NewTextField( ctx *model.Context, d types.Dict, v string, multiLine bool, fonts map[string]types.IndirectRef) (*TextField, *types.IndirectRef, error)
NewTextField returns a new text field for d.