Documentation ¶
Index ¶
- func New(cfgs ...*entity.Config) core.BPDF
- func NewMetricsDecorator(inner core.BPDF) core.BPDF
- type Bpdf
- func (m *Bpdf) AddAutoRow(cols ...core.Col) core.Row
- func (m *Bpdf) AddPages(pages ...core.Page)
- func (m *Bpdf) AddRow(rowHeight float64, cols ...core.Col) core.Row
- func (m *Bpdf) AddRows(rows ...core.Row)
- func (m *Bpdf) FitlnCurrentPage(heightNewLine float64) bool
- func (m *Bpdf) Generate() (core.Document, error)
- func (m *Bpdf) GetCurrentConfig() *entity.Config
- func (m *Bpdf) GetStructure() *node.Node[core.Structure]
- func (m *Bpdf) RegisterFooter(rows ...core.Row) error
- func (m *Bpdf) RegisterHeader(rows ...core.Row) error
- type MetricsDecorator
- func (m *MetricsDecorator) AddAutoRow(cols ...core.Col) core.Row
- func (m *MetricsDecorator) AddPages(pages ...core.Page)
- func (m *MetricsDecorator) AddRow(rowHeight float64, cols ...core.Col) core.Row
- func (m *MetricsDecorator) AddRows(rows ...core.Row)
- func (m *MetricsDecorator) FitlnCurrentPage(heightNewLine float64) bool
- func (m *MetricsDecorator) Generate() (doc core.Document, err error)
- func (m *MetricsDecorator) GetCurrentConfig() *entity.Config
- func (m *MetricsDecorator) GetStructure() *node.Node[core.Structure]
- func (m *MetricsDecorator) RegisterFooter(rows ...core.Row) (err error)
- func (m *MetricsDecorator) RegisterHeader(rows ...core.Row) (err error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New is responsible for create a new instance of core.BPDF. It's optional to provide an *entity.Config with customizations those customization are created by using the config.Builder.
Example ¶
ExampleNew demonstrates how to create a bpdf instance.
package main import ( "github.com/pchchv/bpdf" "github.com/pchchv/bpdf/config" ) func main() { // optional b := config.NewBuilder() cfg := b.Build() m := bpdf.New(cfg) // cfg is an optional // Do things and generate _, _ = m.Generate() }
Output:
func NewMetricsDecorator ¶
NewMetricsDecorator is responsible to create the metrics decorator for the bpdf instance.
Example ¶
ExampleNewMetricsDecorator demonstrates how to create a bpdf metrics decorator instance.
package main import ( "github.com/pchchv/bpdf" "github.com/pchchv/bpdf/config" ) func main() { // optional b := config.NewBuilder() cfg := b.Build() mrt := bpdf.New(cfg) // cfg is an optional m := bpdf.NewMetricsDecorator(mrt) // decorator of bpdf // Do things and generate _, _ = m.Generate() }
Output:
Types ¶
type Bpdf ¶
type Bpdf struct {
// contains filtered or unexported fields
}
func (*Bpdf) AddAutoRow ¶
AddAutoRow is responsible for adding a line with automatic height to the current document. The row height will be calculated based on its content.
func (*Bpdf) AddPages ¶
AddPages is responsible for add pages directly in the document. By adding a page directly, the current cursor will reset and the new page will appear as the next. If the page provided have more rows than the maximum useful area of a page, bpdf will split that page in more than one.
func (*Bpdf) AddRow ¶
AddRow is responsible for add one row in the current document. By adding a row, if the row will extrapolate the useful area of a page, bpdf will automatically add a new page. bpdf use the information of PageSize, PageMargin, FooterSize and HeaderSize to calculate the useful area of a page.
func (*Bpdf) AddRows ¶
AddRows is responsible for add rows in the current document. By adding a row, if the row will extrapolate the useful area of a page, bpdf will automatically add a new page. bpdf use the information of PageSize, PageMargin, FooterSize and HeaderSize to calculate the useful area of a page.
func (*Bpdf) FitlnCurrentPage ¶
FitlnCurrentPage is responsible to validating whether a line fits on the current page.
func (*Bpdf) Generate ¶
Generate computes the component tree created by all other bpdf methods and for generating the PDF document.
func (*Bpdf) GetCurrentConfig ¶
GetCurrentConfig is responsible for returning the current settings from the file.
func (*Bpdf) GetStructure ¶
GetStructure is responsible for return the component tree, this is useful on unit tests cases.
func (*Bpdf) RegisterFooter ¶
RegisterFooter is responsible to define a set of rows as a footer of the document. The footer will appear in every new page of the document. The footer cannot occupy an area greater than the useful area of the page, it this case the method will return an error.
func (*Bpdf) RegisterHeader ¶
RegisterHeader is responsible to define a set of rows as a header of the document. The header will appear in every new page of the document. The header cannot occupy an area greater than the useful area of the page, it this case the method will return an error.
type MetricsDecorator ¶
type MetricsDecorator struct {
// contains filtered or unexported fields
}
func (*MetricsDecorator) AddAutoRow ¶
func (m *MetricsDecorator) AddAutoRow(cols ...core.Col) core.Row
AddAutoRow decorates the AddRow method of bpdf instance.
func (*MetricsDecorator) AddPages ¶
func (m *MetricsDecorator) AddPages(pages ...core.Page)
AddPages decorates the AddPages method of bpdf instance.
func (*MetricsDecorator) AddRows ¶
func (m *MetricsDecorator) AddRows(rows ...core.Row)
AddRows decorates the AddRows method of bpdf instance.
func (*MetricsDecorator) FitlnCurrentPage ¶
func (m *MetricsDecorator) FitlnCurrentPage(heightNewLine float64) bool
FitlnCurrentPage decoratess the FitlnCurrentPage method of bpdf instance.
func (*MetricsDecorator) Generate ¶
func (m *MetricsDecorator) Generate() (doc core.Document, err error)
Generate decorates the Generate method of bpdf instance.
func (*MetricsDecorator) GetCurrentConfig ¶
func (m *MetricsDecorator) GetCurrentConfig() *entity.Config
GetCurrentConfig decorates the GetCurrentConfig method of bpdf instance.
func (*MetricsDecorator) GetStructure ¶
func (m *MetricsDecorator) GetStructure() *node.Node[core.Structure]
GetStructure decorates the GetStructure method of bpdf instance.
func (*MetricsDecorator) RegisterFooter ¶
func (m *MetricsDecorator) RegisterFooter(rows ...core.Row) (err error)
RegisterFooter decorates the RegisterFooter method of bpdf instance.
func (*MetricsDecorator) RegisterHeader ¶
func (m *MetricsDecorator) RegisterHeader(rows ...core.Row) (err error)
RegisterHeader decorates the RegisterHeader method of bpdf instance.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package components contains the public components of bpdf.
|
Package components contains the public components of bpdf. |
code
Package code implements creation of Barcode, MatrixCode and QrCode.
|
Package code implements creation of Barcode, MatrixCode and QrCode. |
col
Package col implements creation of columns.
|
Package col implements creation of columns. |
image
Package image implements creation of images from file and bytes.
|
Package image implements creation of images from file and bytes. |
list
Package list implements creation of lists (old tablelist).
|
Package list implements creation of lists (old tablelist). |
page
Page package implements creation of pages.
|
Page package implements creation of pages. |
row
Package row implements creation of rows.
|
Package row implements creation of rows. |
signature
Package signature implements creation of signatures.
|
Package signature implements creation of signatures. |
text
Package text implements creation of texts.
|
Package text implements creation of texts. |
Package config implements custom configuration builder.
|
Package config implements custom configuration builder. |
The consts package contains the public constants of bpdf.
|
The consts package contains the public constants of bpdf. |
align
The align package contains all align types.
|
The align package contains all align types. |
border
The border package contains all border types.
|
The border package contains all border types. |
breakline
The breakline package contains all break line strategies.
|
The breakline package contains all break line strategies. |
extension
The extension package contains all image extensions.
|
The extension package contains all image extensions. |
fontfamily
The fontfamily package contains all default font families.
|
The fontfamily package contains all default font families. |
fontstyle
The fontstyle package contains all default font styles.
|
The fontstyle package contains all default font styles. |
linestyle
The linestyle package contains all line styles.
|
The linestyle package contains all line styles. |
orientation
Package orientation contains all orientations.
|
Package orientation contains all orientations. |
pagesize
Package pagesize contains all default page sizes.
|
Package pagesize contains all default page sizes. |
protection
The protection package contains all protection types.
|
The protection package contains all protection types. |
provider
The provider package contains all document generation providers.
|
The provider package contains all document generation providers. |
The core package contains all core interfaces and basic implementations.
|
The core package contains all core interfaces and basic implementations. |
internal
|
|
Package merge implements PDF merge.
|
Package merge implements PDF merge. |
Package metrics contains metrics models, constants and formatting.
|
Package metrics contains metrics models, constants and formatting. |
The properties package contain the public properties of bpdf.
|
The properties package contain the public properties of bpdf. |
Package test implements unit test feature.
|
Package test implements unit test feature. |