primitives

package
v0.13.7 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AP

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

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
}

type Border

type Border struct {
	Name  string
	Width int
	Color string `json:"col"`

	Style string
	// contains filtered or unexported fields
}

type Buttons

type Buttons struct {
	Values []string
	Label  *TextFieldLabel
	// contains filtered or unexported fields
}

type CheckBox

type CheckBox struct {
	Label    *TextFieldLabel
	ID       string
	Value    bool       // checked state
	Position [2]float64 `json:"pos"` // x,y

	Width  float64
	Dx, Dy float64

	Margin *Margin // applied to content box
	Hide   bool
	// contains filtered or unexported fields
}

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
	CheckBoxes        []*CheckBox         `json:"checkbox"`         // input checkboxes with optional label
	RadioButtonGroups []*RadioButtonGroup `json:"radiobuttongroup"` // input radiobutton groups with optional label
	// contains filtered or unexported fields
}

func (*Content) BorderRect

func (c *Content) BorderRect() *pdfcpu.Rectangle

func (*Content) Box

func (c *Content) Box() *pdfcpu.Rectangle

type Divider

type Divider struct {
	At float64

	Width int
	Color string `json:"col"`
	// contains filtered or unexported fields
}

type FieldFlags

type FieldFlags int

FieldFlags represents the PDF form field flags.

const (
	FieldReadOnly FieldFlags = 1 << iota
	FieldRequired
	FieldNoExport
	UnusedFlag4
	UnusedFlag5
	UnusedFlag6
	UnusedFlag7
	UnusedFlag8
	UnusedFlag9
	UnusedFlag10
	UnusedFlag11
	UnusedFlag12
	FieldMultiline
	FieldPassword
	FieldNoToggleToOff
	FieldRadio
	FieldPushbutton
	FieldCombo
	FieldEdit
	FieldSort
	FieldFileSelect
	FieldMultiselect
	FieldDoNotSpellCheck
	FieldDoNotScroll
	FieldComb
	FieldRichTextAndRadiosInUnison
	FieldCommitOnSelChange
)

type FormFont

type FormFont struct {
	Name  string
	Size  int
	Color string `json:"col"`
	// contains filtered or unexported fields
}

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
	// contains filtered or unexported fields
}

type ImageBox

type ImageBox struct {
	Name     string
	FileName string     `json:"file"` // path of image file name
	Data     *ImageData // TODO
	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
	// contains filtered or unexported fields
}

type ImageData

type ImageData struct {
	Payload       string // base64 encoded image data
	Format        string // jpeg, png, webp, tiff, ccitt
	Width, Height int
}

type Margin

type Margin struct {
	Name                     string
	Width                    float64
	Top, Right, Bottom, Left float64
}

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
	BackgroundColor string `json:"bgCol"`

	Fonts       map[string]*FormFont // default fonts
	FormFontIDs map[string]string
	FieldIDs    pdfcpu.StringSet
	Fields      pdfcpu.Array
	InheritedDA string
	Header      *HorizontalBand
	Footer      *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"`
	Colors        map[string]string

	DirNames        map[string]string `json:"dirs"`
	FileNames       map[string]string `json:"files"`
	TimestampFormat string            `json:"timestamp"`
	Conf            *pdfcpu.Configuration
	XRefTable       *pdfcpu.XRefTable
	Optimize        *pdfcpu.OptimizationContext
	FontResIDs      map[int]pdfcpu.Dict
	XObjectResIDs   map[int]pdfcpu.Dict
	CheckBoxAPs     map[float64]*AP
	RadioBtnAPs     map[float64]*AP
	HasForm         bool
	// contains filtered or unexported fields
}

func (*PDF) RenderPages

func (pdf *PDF) RenderPages() ([]*pdfcpu.Page, pdfcpu.FontMap, pdfcpu.Array, error)

func (*PDF) Validate

func (pdf *PDF) Validate() error

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            pdfcpu.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"`
	FileNames     map[string]string     `json:"files"`
	Content       *Content
	// contains filtered or unexported fields
}

type Padding

type Padding struct {
	Name                     string
	Width                    float64
	Top, Right, Bottom, Left float64
}

type RadioButtonGroup

type RadioButtonGroup struct {
	Label    *TextFieldLabel
	ID       string
	Value    string     // checked button
	Position [2]float64 `json:"pos"` // x,y

	Width float64

	Orientation string

	Dx, Dy  float64
	Margin  *Margin // applied to content box
	Buttons *Buttons
	Hide    bool
	// contains filtered or unexported fields
}

type Regions

type Regions struct {
	Name        string // unique
	Orientation string `json:"orient"`

	Divider     *Divider `json:"div"`
	Left, Right *Content // 2 horizontal regions or
	Top, Bottom *Content // 2 vertical regions
	// contains filtered or unexported fields
}

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
}

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  []float64 // optional width fractions, 0 < x < 1 must total 1
	ColAnchors []string

	LineHeight      int `json:"lheight"`
	Font            *FormFont
	Margin          *Margin
	Border          *Border
	Padding         *Padding
	BackgroundColor string `json:"bgCol"`
	OddColor        string `json:"oddCol"`
	EvenColor       string `json:"evenCol"`

	Rotation float64 `json:"rot"`
	Grid     bool
	Hide     bool
	Header   *TableHeader
	// contains filtered or unexported fields
}

func (*Table) Height

func (t *Table) Height() float64

type TableHeader

type TableHeader struct {
	Values     []string
	ColAnchors []string

	BackgroundColor string `json:"bgCol"`

	Font *FormFont // defaults to table font
	// contains filtered or unexported fields
}

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
}

type TextField

type TextField struct {
	Label    *TextFieldLabel
	ID       string
	Value    string
	Position [2]float64 `json:"pos"` // x,y

	Width  float64
	Height float64
	Dx, Dy float64

	Multiline       bool
	Font            *FormFont // optional
	Margin          *Margin   // applied to content box
	Border          *Border
	BackgroundColor string `json:"bgCol"`

	Alignment string `json:"align"` // "Left", "Center", "Right"

	RTL      bool
	Rotation float64 `json:"rot"`
	Hide     bool
	// contains filtered or unexported fields
}

type TextFieldLabel

type TextFieldLabel struct {
	TextField
	Width    int
	Gap      int    // horizontal space between textfield and label
	Position string `json:"pos"` // relative to textfield
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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