image

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 7 Imported by: 15

Documentation

Overview

Package image implements creation of images from file and bytes.

Package image implements creation of images from file and bytes.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAutoFromBytesRow added in v2.1.0

func NewAutoFromBytesRow(bytes []byte, extension extension.Type, ps ...props.Rect) core.Row

NewAutoFromBytesRow is responsible to create an instance of an Image wrapped in a automatic row.

func NewAutoFromFileRow added in v2.1.0

func NewAutoFromFileRow(path string, ps ...props.Rect) core.Row

NewFromFileRow is responsible to create an instance of an Image wrapped in a automatic Row.

func NewFromBytes

func NewFromBytes(bytes []byte, extension extension.Type, ps ...props.Rect) core.Component

NewFromBytes is responsible to create an instance of an Image.

Example

ExampleNewFromBytes demonstrates how to create an image component reading bytes.

m := maroto.New()

bytes, _ := os.ReadFile("image.png")

image := image.NewFromBytes(bytes, extension.Png)
col := col.New(12).Add(image)
m.AddRow(10, col)

// generate document
Output:

func NewFromBytesCol

func NewFromBytesCol(size int, bytes []byte, extension extension.Type, ps ...props.Rect) core.Col

NewFromBytesCol is responsible to create an instance of an Image wrapped in a Col.

Example

ExampleNewFromBytesCol demonstrates how to create an image component wrapped into a column reading bytes.

m := maroto.New()

bytes, _ := os.ReadFile("image.png")

imageCol := image.NewFromBytesCol(12, bytes, extension.Png)
m.AddRow(10, imageCol)

// generate document
Output:

func NewFromBytesRow

func NewFromBytesRow(height float64, bytes []byte, extension extension.Type, ps ...props.Rect) core.Row

NewFromBytesRow is responsible to create an instance of an Image wrapped in a Row.

Example

ExampleNewFromBytesRow demonstrates how to create an image component wrapped into a row reading bytes.

m := maroto.New()

bytes, _ := os.ReadFile("image.png")

imageRow := image.NewFromBytesRow(10, bytes, extension.Png)
m.AddRows(imageRow)

// generate document
Output:

func NewFromFile

func NewFromFile(path string, ps ...props.Rect) core.Component

NewFromFile is responsible to create an instance of an Image.

Example

ExampleNewFromFile demonstrates how to create an image component reading file.

m := maroto.New()

image := image.NewFromFile("image.png")
col := col.New(12).Add(image)
m.AddRow(10, col)

// generate document
Output:

func NewFromFileCol

func NewFromFileCol(size int, path string, ps ...props.Rect) core.Col

NewFromFileCol is responsible to create an instance of an Image wrapped in a Col.

Example

ExampleNewFromFileCol demonstrates how to create an image component wrapped into a column reading file.

m := maroto.New()

imageCol := image.NewFromFileCol(12, "image.png")
m.AddRow(10, imageCol)

// generate document
Output:

func NewFromFileRow

func NewFromFileRow(height float64, path string, ps ...props.Rect) core.Row

NewFromFileRow is responsible to create an instance of an Image wrapped in a Row.

Example

ExampleNewFromFileRow demonstrates how to create an image component wrapped into a row reading file.

m := maroto.New()

imageRow := image.NewFromFileRow(10, "image.png")
m.AddRows(imageRow)
// generate document
Output:

Types

type BytesImage

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

func (*BytesImage) GetHeight added in v2.1.0

func (b *BytesImage) GetHeight(provider core.Provider, cell *entity.Cell) float64

GetHeight returns the height that the image will have in the PDF

func (*BytesImage) GetStructure

func (b *BytesImage) GetStructure() *node.Node[core.Structure]

GetStructure returns the Structure of an Image.

func (*BytesImage) Render

func (b *BytesImage) Render(provider core.Provider, cell *entity.Cell)

Render renders an Image into a PDF context.

func (*BytesImage) SetConfig

func (b *BytesImage) SetConfig(config *entity.Config)

SetConfig sets the pdf config.

type FileImage

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

func (*FileImage) GetHeight added in v2.1.0

func (f *FileImage) GetHeight(provider core.Provider, cell *entity.Cell) float64

GetHeight returns the height that the image will have in the PDF

func (*FileImage) GetStructure

func (f *FileImage) GetStructure() *node.Node[core.Structure]

GetStructure returns the Structure of an Image.

func (*FileImage) Render

func (f *FileImage) Render(provider core.Provider, cell *entity.Cell)

Render renders an Image into a PDF context.

func (*FileImage) SetConfig

func (f *FileImage) SetConfig(config *entity.Config)

SetConfig sets the pdf config.

Jump to

Keyboard shortcuts

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