pdf

package
v0.27.3 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Maroto

type Maroto interface {
	// Grid System
	Row(height float64, closure func())
	Col(width uint, closure func())
	ColSpace(gridSize uint)

	// Registers
	RegisterHeader(closure func())
	RegisterFooter(closure func())

	// Outside Col/Row Components
	TableList(header []string, contents [][]string, prop ...props.TableList)
	Line(spaceHeight float64)

	// Inside Col/Row Components
	Text(text string, prop ...props.Text)
	FileImage(filePathName string, prop ...props.Rect) (err error)
	Base64Image(base64 string, extension consts.Extension, prop ...props.Rect) (err error)
	Barcode(code string, prop ...props.Barcode) error
	QrCode(code string, prop ...props.Rect)
	Signature(label string, prop ...props.Font)

	// File System
	OutputFileAndClose(filePathName string) error
	Output() (bytes.Buffer, error)

	// Helpers
	AddPage()
	SetBorder(on bool)
	SetBackgroundColor(color color.Color)
	GetBorder() bool
	GetPageSize() (width float64, height float64)
	GetCurrentPage() int
	GetCurrentOffset() float64
	SetPageMargins(left, top, right float64)
	GetPageMargins() (left float64, top float64, right float64, bottom float64)
	AddUTF8Font(familyStr, styleStr, fileStr string)
	SetProtection(actionFlag byte, userPassStr, ownerPassStr string)
}

Maroto is the principal abstraction to create a PDF document.

func NewMaroto

func NewMaroto(orientation consts.Orientation, pageSize consts.PageSize) Maroto

NewMaroto create a Maroto instance returning a pointer to PdfMaroto Receive an Orientation and a PageSize. Shorthand when using a preset page size from consts.PageSize

func NewMarotoCustomSize added in v0.27.2

func NewMarotoCustomSize(orientation consts.Orientation, pageSize consts.PageSize, unitStr string, width, height float64) Maroto

NewMarotoCustomSize creates a Maroto instance returning a pointer to PdfMaroto Receive an Orientation and a PageSize. Use if custom page size is needed. Otherwise use NewMaroto() shorthand if using page sizes from consts.Pagesize. If using custom width and height, pageSize is just a string value for the format and takes no effect. Width and height inputs are measurements of the page in Portrait orientation.

type PdfMaroto

type PdfMaroto struct {
	Pdf             *gofpdf.Fpdf
	Math            internal.Math
	Font            internal.Font
	TextHelper      internal.Text
	SignHelper      internal.Signature
	Image           internal.Image
	Code            internal.Code
	TableListHelper internal.TableList
	// contains filtered or unexported fields
}

PdfMaroto is the principal structure which implements Maroto abstraction

func (*PdfMaroto) AddPage added in v0.27.2

func (s *PdfMaroto) AddPage()

AddPage adds a new page in the PDF

func (*PdfMaroto) AddUTF8Font added in v0.27.2

func (s *PdfMaroto) AddUTF8Font(familyStr, styleStr, fileStr string)

func (*PdfMaroto) Barcode

func (s *PdfMaroto) Barcode(code string, prop ...props.Barcode) (err error)

Barcode create an barcode inside a cell.

func (*PdfMaroto) Base64Image

func (s *PdfMaroto) Base64Image(base64 string, extension consts.Extension, prop ...props.Rect) error

Base64Image add an Image reading byte slices inside a cell. Defining Image properties.

func (*PdfMaroto) Col

func (s *PdfMaroto) Col(width uint, closure func())

Col create a column inside a row and enable to add components inside.

func (*PdfMaroto) ColSpace

func (s *PdfMaroto) ColSpace(gridSize uint)

ColSpace create an empty column inside a row.

func (*PdfMaroto) FileImage

func (s *PdfMaroto) FileImage(filePathName string, prop ...props.Rect) error

FileImage add an Image reading from disk inside a cell. Defining Image properties.

func (*PdfMaroto) GetBorder

func (s *PdfMaroto) GetBorder() bool

GetBorder return the actual border value.

func (*PdfMaroto) GetCurrentOffset added in v0.27.2

func (s *PdfMaroto) GetCurrentOffset() float64

GetCurrentOffset obtain the current offset in y axis

func (*PdfMaroto) GetCurrentPage

func (s *PdfMaroto) GetCurrentPage() int

GetCurrentPage obtain the current page index this can be used inside a RegisterFooter/RegisterHeader to draw the current page, or to another purposes

func (*PdfMaroto) GetPageMargins added in v0.27.2

func (s *PdfMaroto) GetPageMargins() (left float64, top float64, right float64, bottom float64)

GetPageMargins returns the set page margins. Comes in order of Left, Top, Right, Bottom Default page margins is left: 10, top: 10, right: 10

func (*PdfMaroto) GetPageSize

func (s *PdfMaroto) GetPageSize() (width float64, height float64)

GetPageSize return the actual page size

func (*PdfMaroto) Line

func (s *PdfMaroto) Line(spaceHeight float64)

Line draw a line from margin left to margin right in the currently row.

func (*PdfMaroto) Output

func (s *PdfMaroto) Output() (bytes.Buffer, error)

Output extract PDF in byte slices

func (*PdfMaroto) OutputFileAndClose

func (s *PdfMaroto) OutputFileAndClose(filePathName string) (err error)

OutputFileAndClose save pdf in disk.

func (*PdfMaroto) QrCode

func (s *PdfMaroto) QrCode(code string, prop ...props.Rect)

QrCode create a qrcode inside a cell.

func (*PdfMaroto) RegisterFooter

func (s *PdfMaroto) RegisterFooter(closure func())

RegisterFooter define a sequence of Rows, Lines ou TableLists which will be added in every new page

func (*PdfMaroto) RegisterHeader

func (s *PdfMaroto) RegisterHeader(closure func())

RegisterHeader define a sequence of Rows, Lines ou TableLists which will be added in every new page

func (*PdfMaroto) Row

func (s *PdfMaroto) Row(height float64, closure func())

Row define a row and enable add columns inside the row.

func (*PdfMaroto) SetBackgroundColor added in v0.27.2

func (s *PdfMaroto) SetBackgroundColor(color color.Color)

SetBackgroundColor define the background color of the PDF. This method can be used to toggle background from rows

func (*PdfMaroto) SetBorder

func (s *PdfMaroto) SetBorder(on bool)

SetBorder enable the draw of lines in every cell. Draw borders in all columns created.

func (*PdfMaroto) SetPageMargins added in v0.27.2

func (s *PdfMaroto) SetPageMargins(left, top, right float64)

SetPageMargins overrides default margins (10,10,10) the new page margin will affect all PDF pages

func (*PdfMaroto) SetProtection added in v0.27.2

func (s *PdfMaroto) SetProtection(actionFlag byte, userPassStr, ownerPassStr string)

func (*PdfMaroto) Signature

func (s *PdfMaroto) Signature(label string, prop ...props.Font)

Signature add a space for a signature inside a cell, the space will have a line and a text below

func (*PdfMaroto) TableList

func (s *PdfMaroto) TableList(header []string, contents [][]string, prop ...props.TableList)

TableList create a table with multiple rows and columns. Headers define the amount of columns from each row. Headers have bold style, and localized at the top of table. Contents are array of arrays. Each array is one line.

func (*PdfMaroto) Text

func (s *PdfMaroto) Text(text string, prop ...props.Text)

Text create a text inside a cell.

Jump to

Keyboard shortcuts

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