document

package
v0.0.0-...-71179b8 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultStyle = &Style{FontFamily: "Arial", FontStyle: "", FontSize: 12, TextColor: color.Black, FillColor: color.White, Padding: 2, CellMargin: 1}
View Source
var DefaultStyleBold = &Style{FontFamily: "Arial", FontStyle: "B", FontSize: 12, TextColor: color.Black, FillColor: color.White, Padding: 2, CellMargin: 1}
View Source
var DefaultStyleItalic = &Style{FontFamily: "Arial", FontStyle: "I", FontSize: 12, TextColor: color.Black, FillColor: color.White, Padding: 2, CellMargin: 1}

Functions

This section is empty.

Types

type Document

type Document struct {
	PDF *gofpdf.Fpdf
	// contains filtered or unexported fields
}

Document a layer between Markdown and PDF

func NewDocument

func NewDocument(pdf *gofpdf.Fpdf, defaultStyle *Style) *Document

NewDocument creates a new document

func (*Document) LineBreak

func (d *Document) LineBreak()

LineBreak goes to the beginning of the next line

func (*Document) NewAddCellMarginOption

func (d *Document) NewAddCellMarginOption(margin float64) func(style any) error

NewAddCellMarginOption adds CellMargin

func (*Document) NewAddFontStyleOption

func (d *Document) NewAddFontStyleOption(fontStyle string) func(style any) error

NewAddFontStyleOption adds Font style to the current

func (*Document) NewAddMarginOption

func (d *Document) NewAddMarginOption(margin float64) func(style any) error

NewAddMarginOption adds Left Margin

func (*Document) NewFillColorOption

func (d *Document) NewFillColorOption(color *color.Color) func(style any) error

NewFillColorOption sets Fill Color

func (*Document) NewFontFamilyOption

func (d *Document) NewFontFamilyOption(family string) func(style any) error

NewFontFamilyOption sets Font Family

func (*Document) NewFontSizeOption

func (d *Document) NewFontSizeOption(size float64) func(style any) error

NewFontSizeOption sets Font Size

func (*Document) NewPaddingOption

func (d *Document) NewPaddingOption(padding float64) func(style any) error

NewPaddingOption Adds Left Margin

func (*Document) NewSetCellMarginOption

func (d *Document) NewSetCellMarginOption(margin float64) func(style any) error

NewSetCellMarginOption sets CellMargin

func (*Document) NewSetFontStyleOption

func (d *Document) NewSetFontStyleOption(fontStyle string) func(style any) error

NewSetFontStyleOption sets new Font Style

func (*Document) NewTextColorOption

func (d *Document) NewTextColorOption(color *color.Color) func(style any) error

NewTextColorOption sets Text Color

func (*Document) ResetStyle

func (d *Document) ResetStyle()

ResetStyle resets to previous style in PDF

func (d *Document) SetLink(link string)

SetLink set a variable to specify link element

func (*Document) ThematicBreak

func (d *Document) ThematicBreak()

ThematicBreak add a line break

func (*Document) WithStyle

func (d *Document) WithStyle(opts ...func(style any) error)

func (*Document) Write

func (d *Document) Write(p []byte) (n int, err error)

Write writes a simple slice of bytes. Also needed to satisfy io.Writer interface for `goldmark`

func (*Document) WriteImage

func (d *Document) WriteImage(path string, file io.Reader, _ ...ast.Attribute)

WriteImage draw an image in PDF

func (*Document) WriteTable

func (d *Document) WriteTable(rows ...[]string)

WriteTable draw a table in PDF

type Style

type Style struct {
	FontFamily string
	FontStyle  string
	FontSize   float64

	TextColor *color.Color
	FillColor *color.Color

	Padding    float64
	LeftMargin float64
	CellMargin float64
}

Style for styling texts on the doc

func (*Style) Clone

func (s *Style) Clone() *Style

Clone creates a clone of the style

type Styles

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

Styles holds a list of all applied styles at the moment

func (*Styles) Add

func (s *Styles) Add(style *Style)

Add New style

func (*Styles) Current

func (s *Styles) Current() *Style

Current style

func (*Styles) Pop

func (s *Styles) Pop() *Style

Pop style from the list

Jump to

Keyboard shortcuts

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