code

package
v2.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: MIT Imports: 6 Imported by: 4

Documentation

Overview

Package code implements creation of Barcode, MatrixCode and QrCode. nolint:dupl // It's similar to Barcode.go and it's hard to extract common code.

Package code implements creation of Barcode, MatrixCode and QrCode. nolint:dupl

Package code implements creation of Barcode, MatrixCode and QrCode. nolint:dupl

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAutoBarRow added in v2.1.0

func NewAutoBarRow(code string, ps ...props.Barcode) core.Row

NewAutoBarRow is responsible to create an instance of a Barcode wrapped in a Row with automatic height. using this method the col size will be automatically set to the maximum value

  • code: The value that must be placed in the barcode
  • ps: A set of settings that must be applied to the barcode

func NewAutoMatrixRow added in v2.1.0

func NewAutoMatrixRow(code string, ps ...props.Rect) core.Row

NewAutoMatrixRow is responsible to create an instance of a Matrix code wrapped in a Row with automatic height.

  • code: The value that must be placed in the matrixcode
  • ps: A set of settings that must be applied to the matrixcode

func NewAutoQrRow added in v2.1.0

func NewAutoQrRow(code string, ps ...props.Rect) core.Row

NewAutoMatrixRow is responsible to create an instance of a qrcode wrapped in a Row with automatic height.

  • code: The value that must be placed in the qrcode
  • ps: A set of settings that must be applied to the qrcode

func NewBar

func NewBar(code string, ps ...props.Barcode) core.Component

NewBar is responsible to create an instance of a Barcode.

  • code: The value that must be placed in the barcode
  • ps: A set of settings that must be applied to the barcode
Example

ExampleNewBar demonstrates how to generate a barcode and add it to maroto.

m := maroto.New()

barCode := code.NewBar("123456789", props.Barcode{Percent: 70.5})
col := col.New(6).Add(barCode)
m.AddRow(10, col)

// generate document
Output:

func NewBarCol

func NewBarCol(size int, code string, ps ...props.Barcode) core.Col

NewBarCol is responsible to create an instance of a Barcode wrapped in a Col.

  • size: O tamanho da coluna
  • code: The value that must be placed in the barcode
  • ps: A set of settings that must be applied to the barcode
Example

ExampleNewBarCol demonstrates how to generate a column with a barcode and add it to maroto.

m := maroto.New()

barCodeCol := code.NewBarCol(6, "123456", props.Barcode{Percent: 70.5})
m.AddRow(10, barCodeCol)

// generate document
Output:

func NewBarRow

func NewBarRow(height float64, code string, ps ...props.Barcode) core.Row

NewBarRow is responsible to create an instance of a Barcode wrapped in a Row. using this method the col size will be automatically set to the maximum value

  • height: The height of the line
  • code: The value that must be placed in the barcode
  • ps: A set of settings that must be applied to the barcode
Example

ExampleNewBarRow demonstrates how to generate a row with a barcode and add it to maroto.

m := maroto.New()

barCodeRow := code.NewBarRow(10, "123456789", props.Barcode{Percent: 70.5})
m.AddRows(barCodeRow)

// generate document
Output:

func NewMatrix

func NewMatrix(code string, barcodeProps ...props.Rect) core.Component

NewMatrix is responsible to create an instance of a MatrixCode.

Example

ExampleNewMatrix demonstrates how to generate a matrixcode and add it to maroto.

m := maroto.New()

matrixCode := code.NewMatrix("123456789", props.Rect{Percent: 70.5})
col := col.New(6).Add(matrixCode)
m.AddRow(10, col)

// generate document
Output:

func NewMatrixCol

func NewMatrixCol(size int, code string, ps ...props.Rect) core.Col

NewMatrixCol is responsible to create an instance of a MatrixCode wrapped in a Col.

Example

ExampleNewMatrixCol demonstrates how to generate a column with a matrixcode and add it to maroto.

m := maroto.New()

matrixCodeCol := code.NewMatrixCol(12, "123456789", props.Rect{Percent: 70.5})
m.AddRow(10, matrixCodeCol)

// generate document
Output:

func NewMatrixRow

func NewMatrixRow(height float64, code string, ps ...props.Rect) core.Row

NewMatrixRow is responsible to create an instance of a MatrixCode wrapped in a Row.

Example

ExampleNewMatrixRow demonstrates how to generate a row with a matrixcode and add it to maroto.

m := maroto.New()

matrixCodeRow := code.NewMatrixRow(10, "123456789", props.Rect{Percent: 70.5})
m.AddRows(matrixCodeRow)

// generate document
Output:

func NewQr

func NewQr(code string, barcodeProps ...props.Rect) core.Component

NewQr is responsible to create an instance of a QrCode.

Example

ExampleNewQr demonstrates how to generate a qrcode and add it to maroto.

m := maroto.New()

qrCode := code.NewQr("123456789", props.Rect{Percent: 70.5})
col := col.New(6).Add(qrCode)
m.AddRow(10, col)

// generate document
Output:

func NewQrCol

func NewQrCol(size int, code string, ps ...props.Rect) core.Col

NewQrCol is responsible to create an instance of a QrCode wrapped in a Col.

Example

ExampleNewQrCol demonstrates how to generate a column with a qrcode and add it to maroto.

m := maroto.New()

qrCodeCol := code.NewQrCol(12, "123456789", props.Rect{Percent: 70.5})
m.AddRow(10, qrCodeCol)

// generate document
Output:

func NewQrRow

func NewQrRow(height float64, code string, ps ...props.Rect) core.Row

NewQrRow is responsible to create an instance of a QrCode wrapped in a Row.

Example

ExampleNewQrRow demonstrates how to generate a row with a qrcode and add it to maroto.

m := maroto.New()

qrCodeRow := code.NewQrRow(10, "123456789", props.Rect{Percent: 70.5})
m.AddRows(qrCodeRow)

// generate document
Output:

Types

type Barcode

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

func (*Barcode) GetHeight added in v2.1.0

func (b *Barcode) GetHeight(provider core.Provider, cell *entity.Cell) float64

GetHeight returns the height that the barcode will have in the PDF

func (*Barcode) GetStructure

func (b *Barcode) GetStructure() *node.Node[core.Structure]

GetStructure returns the structure of a barcode. This method is typically used when creating tests

func (*Barcode) Render

func (b *Barcode) Render(provider core.Provider, cell *entity.Cell)

Render renders a Barcode into a PDF context. The maroto cal this methodo in process to generate the pdf.

  • provider: Is the creator provider used to generate the pdf
  • cell: cell represents the space available to draw the component

func (*Barcode) SetConfig

func (b *Barcode) SetConfig(config *entity.Config)

SetConfig sets the configuration of a Barcode.

type MatrixCode

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

func (*MatrixCode) GetHeight added in v2.1.0

func (m *MatrixCode) GetHeight(provider core.Provider, cell *entity.Cell) float64

GetHeight returns the height that the code will have in the PDF

func (*MatrixCode) GetStructure

func (m *MatrixCode) GetStructure() *node.Node[core.Structure]

GetStructure returns the Structure of a MatrixCode.

func (*MatrixCode) Render

func (m *MatrixCode) Render(provider core.Provider, cell *entity.Cell)

Render renders a MatrixCode into a PDF context.

func (*MatrixCode) SetConfig

func (m *MatrixCode) SetConfig(config *entity.Config)

SetConfig sets the configuration of a MatrixCode.

type QrCode

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

func (*QrCode) GetHeight added in v2.1.0

func (q *QrCode) GetHeight(provider core.Provider, cell *entity.Cell) float64

GetHeight returns the height that the QrCode will have in the PDF

func (*QrCode) GetStructure

func (q *QrCode) GetStructure() *node.Node[core.Structure]

GetStructure returns the Structure of a QrCode.

func (*QrCode) Render

func (q *QrCode) Render(provider core.Provider, cell *entity.Cell)

Render renders a QrCode into a PDF context.

func (*QrCode) SetConfig

func (q *QrCode) SetConfig(config *entity.Config)

SetConfig set the config for the component.

Jump to

Keyboard shortcuts

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