Documentation ¶
Index ¶
- func CreatePDFInProjectRootOutFolder(pdf *gofpdf.Fpdf, fileName string) error
- type AlignmentType
- type BorderType
- type BoxType
- type CellType
- type ColumnType
- type Doc
- func (doc *Doc) AddImage(dto *Image) (*gofpdf.ImageInfoType, error)
- func (d *Doc) CFormat(w, h float64, txtStr, borderStr string, ln int, alignStr string, fill bool, ...)
- func (d *Doc) Ellipsis() string
- func (d *Doc) GetFontLineHeight() float64
- func (d *Doc) GetLineHeight() float64
- func (d *Doc) GetPrintHeight() float64
- func (d *Doc) GetPrintWidth() float64
- func (d *Doc) GetRemainingPrintHeight() float64
- func (d *Doc) MCell(w, h float64, txtStr, borderStr, alignStr string, fill bool)
- func (d *Doc) SetLineHeight(lh float64)
- func (d *Doc) VerticalLine(x1, x2, thickness float64)
- func (d *Doc) VerticalLinePrintWidth()
- type DocTable
- func (t *DocTable) Generate() error
- func (t *DocTable) SetAllCellAligns(a AlignmentType)
- func (t *DocTable) SetAllCellBorders(b bool)
- func (t *DocTable) SetAllCellLineHeightFactors(f float64)
- func (t *DocTable) SetAllCellPaddings(p Padding)
- func (t *DocTable) SetAllCellStyleFuncs(f *func(gofpdf.Fpdf))
- func (t *DocTable) SetAllCellTypes(ct CellType)
- func (t *DocTable) SetAllColFixedWidths(w float64)
- func (t *DocTable) SetAllColGaps(g float64)
- func (t *DocTable) SetAllColTypes(ct ColumnType)
- func (t *DocTable) SetAllRowFixedHeights(f float64)
- func (t *DocTable) SetAllRowGaps(g float64)
- func (t *DocTable) SetAllRowTypes(rt RowType)
- func (t *DocTable) SetCell(i, j int, str string) error
- func (t *DocTable) SetCellAlingsPerColumn(a []AlignmentType) error
- func (t *DocTable) SetCellPaddings(p [][]Padding) error
- func (t *DocTable) SetCellPaddingsPerColumn(p []Padding) error
- func (t *DocTable) SetCellStyleFuncsPerAlternateRows(f1, f2 *func(gofpdf.Fpdf))
- func (t *DocTable) SetCellStyleFuncsPerColumn(fs []*func(gofpdf.Fpdf)) error
- func (t *DocTable) SetCellStyleFuncsPerRow(fs []*func(gofpdf.Fpdf)) error
- func (t *DocTable) SetCellStyleFuncsRow(i int, f *func(gofpdf.Fpdf)) error
- func (t *DocTable) SetCellType(i, j int, ct CellType) error
- func (t *DocTable) SetCellTypesPerColumn(ct []CellType) error
- func (t *DocTable) SetColFixedWidths(cFixedWidth []float64) error
- func (t *DocTable) SetColGaps(g []float64) error
- func (t *DocTable) SetColTypes(colTypes []ColumnType) error
- func (t *DocTable) SetDefaults()
- func (t *DocTable) SetHeadType(ht HeadType)
- func (t *DocTable) SetRowFixedHeights(f []float64) error
- func (t *DocTable) SetRowGaps(g []float64) error
- func (t *DocTable) SetRowTypes(rt []RowType) error
- type FillType
- type FlowType
- type HAlignmentType
- type HeadType
- type Image
- type LayoutType
- type OrientationType
- type Padding
- type PositionType
- type RowType
- type UnitType
- type VAlignmentType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlignmentType ¶
type AlignmentType int
AlignmentType determines how the content is aligned inside a cell.
cell: #----------------------------------------------# | AlignTopLeft AlignTop AlignTopRight | | | | AlignLeft AlignCenter AlignRight | | | | AlignBottomLeft AlignBottom AlignBottomRight | #----------------------------------------------#
Possible values:
- AlignCenter
- AlignTop
- AlignRight
- AlignBottom
- AlignLeft
- AlignTopLeft
- AlignTopRight
- AlignBottomRight
- AlignBottomLeft
const ( AlignCenter AlignmentType = iota AlignTop AlignRight AlignBottom AlignLeft AlignTopLeft AlignTopRight AlignBottomRight AlignBottomLeft )
type BorderType ¶
type BorderType int
BorderType determines how a border will be rendered.
Possible values:
- BorderNone
- BorderOutside
- BorderInside
- BorderTop
- BorderRight
- BorderBottom
- BorderLeft
- BorderX
- BorderY
- BorderTopAndLeft
- BorderTopAndRight
- BorderBottomAndRight
- BorderBottomAndLeft
- BorderOpenTop
- BorderOpenRight
- BorderOpenBottom
- BorderOpenLeft
const ( BorderUnset BorderType = iota BorderNone BorderOutside BorderInside // e.g. table BorderTop BorderRight BorderBottom BorderLeft BorderX // BorderLeft + BorderRight BorderY // BorderTop + BorderBottom BorderTopAndLeft BorderTopAndRight BorderBottomAndRight BorderBottomAndLeft BorderOpenTop // BorderRight + BorderBottom + BorderLeft BorderOpenRight // BorderBottom + BorderLeft + BorderTop BorderOpenBottom // BorderLeft + BorderTop + BorderRight BorderOpenLeft // BorderTop + BorderRight + BorderBottom )
type BoxType ¶
type BoxType int
BoxType determines if content has to fit inside the box or it will be continued on another box on the same or subsequent page.
BoxUnset (default) - BoxType is not set ¶
BoxOpen - content will be continued when it does not fit the box entirely.
BoxClosed - content has to fit the box, otherwise this should lead to an error.
type ColumnType ¶
type ColumnType int
CollumnType determines how a column width will be calculated.
const ( ColCalc ColumnType = iota ColFixed ColDyn )
type Doc ¶
func NewA4 ¶
func NewA4() *Doc
NewA4 creates a new pdf in DIN A4 format with one page added.
Orientation: portrait
lang: en
unit: mm
size: A4
font: Arial
fontSize: 8
lineHeight: 1.2
document margins: left: 10, top: 10, right: 10
line width: 0.2
func NewA4WithDefaults ¶
NewA4 creates a new pdf in DIN A4 format with one page added.
Orientation: portrait
lang: en
unit: mm
size: A4
font: Arial
fontSize: 8
lineHeight: 1.2
document margins: left: 10, top: 10, right: 10
line width: 0.2
func (*Doc) CFormat ¶
func (d *Doc) CFormat(w, h float64, txtStr, borderStr string, ln int, alignStr string, fill bool, link int, linkStr string)
CFormat wraps CellFormat and transforms the given txtStr in a UTF-8 UnicodeTranslator to render special characters such as german Umlaute
func (*Doc) Ellipsis ¶
Ellipsis are three dots (...) representing that a string is longer than it is displayed
func (*Doc) GetFontLineHeight ¶
func (*Doc) GetLineHeight ¶
func (*Doc) GetPrintHeight ¶
GetPrintHeight returns the current print height, which is the page height subtracted by the top and bottom margin.
func (*Doc) GetPrintWidth ¶
GetPrintWidth returns the current print width, which is the page width subtracted by the left and right margin.
func (*Doc) GetRemainingPrintHeight ¶
GetRemainingPrintHeight returns the remaining print height, which is the page height subtracted by the bottom margin and the current cursor-position, can be negative.
func (*Doc) MCell ¶
CFormat wraps MultiCell and transforms the given txtStr in a UTF-8 UnicodeTranslator to render special characters such as german Umlaute
func (*Doc) SetLineHeight ¶
SetLineHeight sets the line height. Values 0 and lower will be disgarded.
func (*Doc) VerticalLine ¶
VerticalLine draws a vertical line on the current y position from x1 to x2 with a given thinkness.
func (*Doc) VerticalLinePrintWidth ¶
func (d *Doc) VerticalLinePrintWidth()
VerticalLinePrintWidth draws a vertical line inside the current print width with a thickness of Fpdf.GetLineWidth().
type DocTable ¶
type DocTable struct {
// contains filtered or unexported fields
}
DocTable
NOTE: All used indices follow the convention that indices i are for rows and indices j are for columns.
Render process: 1-3 are user actions
1. NewDocTable(doc *Doc, cells [][]string)
setting row and column count
setting default values
2. (optional) change table parameters
3. table.Generate()
validate columns
calculate columns
validate rows
calculate rows
render cells
Table parameters & defaults:
- colTypes: ColDyn
- colFixedWidths: 0.0
- colGaps: 0.0
- colWidths: calculated
- rowTypes: RowCalc
- rowFixedHeights: 0.0
- rowGaps: 0.0
- rowHeights: calculated
- cells: constructor parameter
- cellTypes: CellSingle
- cellLineHeightFactors: 1.2
- cellAligns: AlignLeft
- cellPaddings: Padding{0,0,0,0}
- cellBorder: true
func NewDocTable ¶
NewDocTable creats a DocTable given a *Doc and cells. An error will be returned when given cell dimensions are not valid (e.g. one row is shorter than the others).
func (*DocTable) SetAllCellAligns ¶
func (t *DocTable) SetAllCellAligns(a AlignmentType)
func (*DocTable) SetAllCellBorders ¶
func (*DocTable) SetAllCellLineHeightFactors ¶
func (*DocTable) SetAllCellPaddings ¶
func (*DocTable) SetAllCellStyleFuncs ¶
TODO: Add SetCellStyleFunc
func (*DocTable) SetAllCellTypes ¶
func (*DocTable) SetAllColFixedWidths ¶
func (*DocTable) SetAllColGaps ¶
func (*DocTable) SetAllColTypes ¶
func (t *DocTable) SetAllColTypes(ct ColumnType)
func (*DocTable) SetAllRowFixedHeights ¶
func (*DocTable) SetAllRowGaps ¶
func (*DocTable) SetAllRowTypes ¶
func (*DocTable) SetCellAlingsPerColumn ¶
func (t *DocTable) SetCellAlingsPerColumn(a []AlignmentType) error
func (*DocTable) SetCellPaddings ¶
func (*DocTable) SetCellPaddingsPerColumn ¶
func (*DocTable) SetCellStyleFuncsPerAlternateRows ¶
func (*DocTable) SetCellStyleFuncsPerColumn ¶
func (*DocTable) SetCellStyleFuncsPerRow ¶
func (*DocTable) SetCellStyleFuncsRow ¶
func (*DocTable) SetCellTypesPerColumn ¶
func (*DocTable) SetColFixedWidths ¶
func (*DocTable) SetColGaps ¶
func (*DocTable) SetColTypes ¶
func (t *DocTable) SetColTypes(colTypes []ColumnType) error
func (*DocTable) SetDefaults ¶
func (t *DocTable) SetDefaults()
func (*DocTable) SetRowFixedHeights ¶
func (*DocTable) SetRowGaps ¶
func (*DocTable) SetRowTypes ¶
type FlowType ¶
type FlowType int
FlowType determines where the cursor will positioned after generate.
FlowInline - cursor on the same height after the element.
FlowBlock - cursor under and at the beginning of the element.
FlowNewline - cursor under the element and at the left margin
type HAlignmentType ¶
type HAlignmentType int
HAlignmentType determines how content is aligned horizontally in a cell:
#-----------------------------------------# | | | HAlignLeft HAlignCenter HAlignRight | | | #-----------------------------------------#
const ( HAlignUnset HAlignmentType = iota HAlignLeft HAlignCenter HAlignRight )
type LayoutType ¶
type LayoutType string
const ( LayoutTypeDIN5008A LayoutType = "DIN_5008A" LayoutTypeDIN5008B LayoutType = "DIN_5008B" )
type OrientationType ¶
type OrientationType int
const ( OrientationUnset OrientationType = iota OrientationPortrait OrientationLandscape )
type Padding ¶
type Padding [4]float64
Padding is the padding inside of a cell. The indices follow the convention Top(0), Right(1), Bottom(2), Left(3).
#-- border -------------------------# | paddingTop | | #------# | | paddingLeft | cell | paddingRight | | #------# | | paddingBottom | #-----------------------------------#
type PositionType ¶
type PositionType int
PositionType determines how an element gets positioned.
PositionAbsolute - place an element at the coordinates x, y on the current page.
PositionsRelative - place an element at the current cursor position.
const ( PositionUnset PositionType = iota PositionAbsolute PositionRelative )
type VAlignmentType ¶
type VAlignmentType int
VAlignmentType determines how content is aligned vertically in a cell:
#------------------# | VAlignTop | | | | VAlignMiddle | | | | VAlignBottom | #------------------#
const ( VAlignUnset VAlignmentType = iota VAlignTop VAlignMiddle VAlignBottom )