core

package
v2.0.0-beta.19 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 10 Imported by: 19

Documentation

Overview

Package core contains all core interfaces and basic implementations.

Package core contains all core interfaces and basic implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code interface {
	GenQr(code string) (*entity.Image, error)
	GenDataMatrix(code string) (*entity.Image, error)
	GenBar(code string, cell *entity.Cell, prop *props.Barcode) (*entity.Image, error)
}

Code is the abstraction which deals of how to add QrCodes or Barcode in a PDF.

type Col

type Col interface {
	Node
	Add(components ...Component) Col
	GetSize() int
	WithStyle(style *props.Cell) Col
	Render(provider Provider, cell entity.Cell, createCell bool)
}

Col is the interface that wraps the basic methods of a col.

type Component

type Component interface {
	Node
	Render(provider Provider, cell *entity.Cell)
}

Component is the interface that wraps the basic methods of a component.

type Document

type Document interface {
	GetBytes() []byte
	GetBase64() string
	Save(file string) error
	GetReport() *metrics.Report
	Merge([]byte) error
}

Document is the interface that wraps the basic methods of a document.

func NewPDF

func NewPDF(bytes []byte, report *metrics.Report) Document

NewPDF is responsible to create a new instance of PDF.

type Font

type Font interface {
	SetFamily(family string)
	SetStyle(style fontstyle.Type)
	SetSize(size float64)
	SetFont(family string, style fontstyle.Type, size float64)
	GetFamily() string
	GetStyle() fontstyle.Type
	GetSize() float64
	GetFont() (string, fontstyle.Type, float64)
	GetHeight(family string, style fontstyle.Type, size float64) float64
	SetColor(color *props.Color)
	GetColor() *props.Color
}

Font is the abstraction which deals of how to set fontstyle configurations.

type Image

type Image interface {
	Add(img *entity.Image, cell *entity.Cell, margins *entity.Margins, prop *props.Rect, extension extension.Type, flow bool) error
}

Image is the abstraction which deals of how to add images in a PDF.

type Line

type Line interface {
	Add(cell *entity.Cell, prop *props.Line)
}

type Maroto

type Maroto interface {
	RegisterHeader(rows ...Row) error
	RegisterFooter(rows ...Row) error
	AddRows(rows ...Row)
	AddRow(rowHeight float64, cols ...Col) Row
	FitlnCurrentPage(heightNewLine float64) bool
	AddPages(pages ...Page)
	GetStructure() *node.Node[Structure]
	Generate() (Document, error)
}

Maroto is the interface that wraps the basic methods of maroto.

type Math

type Math interface {
	GetInnerCenterCell(inner *entity.Dimensions, outer *entity.Dimensions, percent float64) *entity.Cell
	GetInnerNonCenterCell(inner *entity.Dimensions, outer *entity.Dimensions, prop *props.Rect) *entity.Cell
}

Math is the abstraction which deals with useful calc.

type Node

type Node interface {
	SetConfig(config *entity.Config)
	GetStructure() *node.Node[Structure]
}

Node is the interface that wraps the basic methods of a node.

type Page

type Page interface {
	Node
	Add(rows ...Row) Page
	GetRows() []Row
	GetNumber() int
	SetNumber(number int, total int)
	Render(provider Provider, cell entity.Cell)
}

Page is the interface that wraps the basic methods of a page.

type Pdf

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

func (*Pdf) GetBase64

func (p *Pdf) GetBase64() string

GetBase64 returns the PDF bytes in base64.

func (*Pdf) GetBytes

func (p *Pdf) GetBytes() []byte

GetBytes returns the PDF bytes.

func (*Pdf) GetReport

func (p *Pdf) GetReport() *metrics.Report

GetReport returns the metrics.Report.

func (*Pdf) Merge

func (p *Pdf) Merge(bytes []byte) error

Merge merges the PDF with another PDF.

func (*Pdf) Save

func (p *Pdf) Save(file string) error

Save saves the PDF in a file.

type Provider

type Provider interface {
	// Grid
	CreateRow(height float64)
	CreateCol(width, height float64, config *entity.Config, prop *props.Cell)

	// Features
	AddLine(cell *entity.Cell, prop *props.Line)
	AddText(text string, cell *entity.Cell, prop *props.Text)
	GetTextHeight(prop *props.Font) float64
	AddMatrixCode(code string, cell *entity.Cell, prop *props.Rect)
	AddQrCode(code string, cell *entity.Cell, rect *props.Rect)
	AddBarCode(code string, cell *entity.Cell, prop *props.Barcode)
	AddImageFromFile(value string, cell *entity.Cell, prop *props.Rect)
	AddImageFromBytes(bytes []byte, cell *entity.Cell, prop *props.Rect, extension extension.Type)
	AddBackgroundImageFromBytes(bytes []byte, cell *entity.Cell, prop *props.Rect, extension extension.Type)

	// General
	GenerateBytes() ([]byte, error)

	SetProtection(protection *entity.Protection)
	SetCompression(compression bool)
	SetMetadata(metadata *entity.Metadata)
}

Provider is the abstraction of a document creator provider.

type Row

type Row interface {
	Node
	Add(cols ...Col) Row
	GetHeight() float64
	GetColumns() []Col
	WithStyle(style *props.Cell) Row
	Render(provider Provider, cell entity.Cell)
}

Row is the interface that wraps the basic methods of a row.

type Structure

type Structure struct {
	Type    string
	Value   interface{}
	Details map[string]interface{}
}

Structure is the representation of the component tree structure.

type Text

type Text interface {
	Add(text string, cell *entity.Cell, textProp *props.Text)
	GetLinesQuantity(text string, fontFamily props.Text, colWidth float64) int
}

Text is the abstraction which deals of how to add text inside PDF.

Directories

Path Synopsis
Package entity contains all core entities.
Package entity contains all core entities.

Jump to

Keyboard shortcuts

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