fpdf

package
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2025 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package fpdf provides helper utilities for accessing the underlying Fpdf interface from Maroto providers for advanced drawing operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFpdf

func GetFpdf(provider core.Provider) (gofpdfwrapper.Fpdf, bool)

GetFpdf safely extracts the underlying gofpdfwrapper.Fpdf interface from a Provider. Returns the Fpdf interface and true if successful, nil and false otherwise.

Example usage:

if fpdf, ok := fpdf.GetFpdf(provider); ok {
    // Use fpdf methods directly
    fpdf.SetFillColor(255, 0, 0)
    fpdf.Rect(10, 10, 50, 20, "F")
}

func GetFpdfFromMaroto

func GetFpdfFromMaroto(maroto core.Maroto) (gofpdfwrapper.Fpdf, bool)

GetFpdfFromMaroto safely extracts the underlying gofpdfwrapper.Fpdf interface from a Maroto instance. This is a convenience method that combines GetProvider() and GetFpdf().

Example usage:

if fpdf, ok := fpdf.GetFpdfFromMaroto(maroto); ok {
    // Use fpdf methods directly
    fpdf.SetDrawColor(0, 255, 0)
    fpdf.Line(0, 0, 100, 100)
}

Types

type DrawingHelper

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

DrawingHelper provides convenience methods for common drawing operations.

func NewDrawingHelper

func NewDrawingHelper(provider core.Provider) *DrawingHelper

NewDrawingHelper creates a new DrawingHelper from a Provider. Returns nil if the provider doesn't support Fpdf interface.

func NewDrawingHelperFromMaroto

func NewDrawingHelperFromMaroto(maroto core.Maroto) *DrawingHelper

NewDrawingHelperFromMaroto creates a new DrawingHelper from a Maroto instance. Returns nil if the maroto instance doesn't support Fpdf interface.

func (*DrawingHelper) DrawCircle

func (dh *DrawingHelper) DrawCircle(x, y, radius float64, styleStr string)

DrawCircle draws a circle with the specified style. styleStr can be "D", "F", "DF", or "FD"

func (*DrawingHelper) DrawLine

func (dh *DrawingHelper) DrawLine(x1, y1, x2, y2 float64)

DrawLine draws a line from (x1, y1) to (x2, y2).

func (*DrawingHelper) DrawPolygon

func (dh *DrawingHelper) DrawPolygon(points [][]float64, styleStr string)

DrawPolygon draws a polygon using the provided points. points should be in format [][]float64{{x1,y1}, {x2,y2}, ...} styleStr can be "D", "F", "DF", or "FD"

func (*DrawingHelper) DrawRect

func (dh *DrawingHelper) DrawRect(x, y, w, h float64, styleStr string)

DrawRect draws a rectangle with the specified fill and border. styleStr can be: - "D" or "" for border only - "F" for filled only - "DF" or "FD" for both border and fill

func (*DrawingHelper) GetFpdf

func (dh *DrawingHelper) GetFpdf() gofpdfwrapper.Fpdf

GetFpdf returns the underlying Fpdf interface for direct access to all methods.

func (*DrawingHelper) SetDrawColor

func (dh *DrawingHelper) SetDrawColor(r, g, b int)

SetDrawColor sets the draw/border color for subsequent drawing operations.

func (*DrawingHelper) SetFillColor

func (dh *DrawingHelper) SetFillColor(r, g, b int)

SetFillColor sets the fill color for subsequent drawing operations.

Jump to

Keyboard shortcuts

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