col

package
v0.0.0-...-40a6ac2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package col implements creation of columns.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(size ...int) core.Col

New is responsible to create an instance of core.Col.

Example

ExampleNew demonstrates how to create a Col instance.

package main

import (
	"github.com/pchchv/bpdf"
	"github.com/pchchv/bpdf/components/col"
	"github.com/pchchv/bpdf/components/row"
)

func main() {
	// size is an optional parameters, if not provided, bpdf
	// will apply the maximum size, even if custom size is applied.
	size := 12
	col := col.New(size)

	row := row.New(10).Add(col)

	m := bpdf.New()
	m.AddRows(row)

	// Do things and generate
	_, _ = m.Generate()
}
Output:

Types

type Col

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

func (*Col) Add

func (c *Col) Add(components ...core.Component) core.Col

Add is responsible to add a component to a core.Col.

Example

ExampleCol_Add demonstrates how to add components to Col.

package main

import (
	"github.com/pchchv/bpdf"
	"github.com/pchchv/bpdf/components/code"
	"github.com/pchchv/bpdf/components/col"
	"github.com/pchchv/bpdf/components/row"
	"github.com/pchchv/bpdf/components/signature"
	"github.com/pchchv/bpdf/components/text"
)

func main() {
	col := col.New()

	text := text.New("text content")
	qrCode := code.NewQr("qrcode")
	signature := signature.New("signature label")

	col.Add(text, qrCode, signature)

	row := row.New(10).Add(col)

	m := bpdf.New()
	m.AddRows(row)

	// Do things and generate
	_, _ = m.Generate()
}
Output:

func (*Col) GetHeight

func (c *Col) GetHeight(provider core.Provider, cell *entity.Cell) float64

GetHeight returns the height of the column content

func (*Col) GetSize

func (c *Col) GetSize() int

GetSize returns the size of a core.Col.

func (*Col) GetStructure

func (c *Col) GetStructure() *node.Node[core.Structure]

GetStructure returns the Structure of a core.Col.

func (*Col) Render

func (c *Col) Render(provider core.Provider, cell entity.Cell, createCell bool)

Render renders a core.Col into a PDF context.

func (*Col) SetConfig

func (c *Col) SetConfig(config *entity.Config)

SetConfig set the config for the component.

func (*Col) WithStyle

func (c *Col) WithStyle(style *properties.Cell) core.Col

WithStyle sets the style for the column.

Example

ExampleCol_WithStyle demonstrates how to add style to Col.

package main

import (
	"github.com/pchchv/bpdf"
	"github.com/pchchv/bpdf/components/col"
	"github.com/pchchv/bpdf/components/row"
	"github.com/pchchv/bpdf/consts/border"
	"github.com/pchchv/bpdf/consts/linestyle"
	"github.com/pchchv/bpdf/properties"
)

func main() {
	col := col.New()
	col.WithStyle(&properties.Cell{
		BackgroundColor: &properties.Color{
			Red:   10,
			Green: 100,
			Blue:  150,
		},
		BorderColor: &properties.Color{
			Red:   55,
			Green: 10,
			Blue:  60,
		},
		BorderType:      border.Full,
		BorderThickness: 0.1,
		LineStyle:       linestyle.Dashed,
	})

	row := row.New(10).Add(col)
	m := bpdf.New()
	m.AddRows(row)

	// Do things and generate
	_, _ = m.Generate()
}
Output:

Jump to

Keyboard shortcuts

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