cssbuilder

package
v0.0.0-...-3435f2a Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: BSD-3-Clause Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSSBuilder

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

CSSBuilder handles HTML chunks and CSS instructions.

func New

func New(fd *frontend.Document, c *csshtml.CSS) *CSSBuilder

New creates an instance of the CSSBuilder.

func (*CSSBuilder) AddCSS

func (cb *CSSBuilder) AddCSS(css string) error

AddCSS reads the CSS instructions in css.

func (*CSSBuilder) BeforeShipout

func (cb *CSSBuilder) BeforeShipout() error

BeforeShipout should be called when placing a CSS page in the PDF. It adds page margin boxes to the current page.

func (*CSSBuilder) CreateVlist

func (cb *CSSBuilder) CreateVlist(te *frontend.Text, wd bag.ScaledPoint) (*node.VList, error)

CreateVlist converts the te into a big vlist.

func (*CSSBuilder) HTMLToText

func (cb *CSSBuilder) HTMLToText(html string) (*frontend.Text, error)

HTMLToText interprets the HTML string and applies all previously read CSS data.

func (*CSSBuilder) InitPage

func (cb *CSSBuilder) InitPage() error

InitPage makes sure that there is a valid page in the frontend.

func (*CSSBuilder) NewPage

func (cb *CSSBuilder) NewPage() error

NewPage puts the current page into the PDF document and starts with a new page.

func (*CSSBuilder) OutputAt

func (cb *CSSBuilder) OutputAt(text *frontend.Text, x, y, width bag.ScaledPoint) error

OutputAt places the text at the given coordinates and formats it to the given width. OutputAt inserts page breaks if necessary.

func (*CSSBuilder) OutputPage

func (cb *CSSBuilder) OutputPage(html string) error

OutputPage outputs the HTML text and breaks pages when necessary.

func (*CSSBuilder) PageSize

func (cb *CSSBuilder) PageSize() (PageDimensions, error)

PageSize returns a struct with the dimensions of the current page.

func (*CSSBuilder) ParseCSSString

func (cb *CSSBuilder) ParseCSSString(css string) error

ParseCSSString reads CSS instructions from a string.

func (*CSSBuilder) ParseHTMLFromNode

func (cb *CSSBuilder) ParseHTMLFromNode(input *html.Node) (*frontend.Text, error)

ParseHTMLFromNode interprets the HTML structure and applies all previously read CSS data.

func (*CSSBuilder) ReadCSSFile

func (cb *CSSBuilder) ReadCSSFile(filename string) error

ReadCSSFile reads the given file name and tries to parse the CSS contents from the file.

func (*CSSBuilder) ShowCSS

func (cb *CSSBuilder) ShowCSS() string

ShowCSS returns a CSS dump

type PageDimensions

type PageDimensions struct {
	Width         bag.ScaledPoint
	Height        bag.ScaledPoint
	MarginLeft    bag.ScaledPoint
	MarginRight   bag.ScaledPoint
	MarginTop     bag.ScaledPoint
	MarginBottom  bag.ScaledPoint
	PageAreaLeft  bag.ScaledPoint
	PageAreaTop   bag.ScaledPoint
	ContentWidth  bag.ScaledPoint
	ContentHeight bag.ScaledPoint
	// contains filtered or unexported fields
}

PageDimensions contains the page size and the margins of the page.

Jump to

Keyboard shortcuts

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