pdf

package
v1.21.21 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VerticalTop      VerticalPosition   = "top"
	VerticalBottom   VerticalPosition   = "bottom"
	VerticalCenter   VerticalPosition   = "" // center is the default
	HorizontalLeft   HorizontalPosition = "left"
	HorizontalRight  HorizontalPosition = "right"
	HorizontalCenter HorizontalPosition = "" // center is the default
	InsideTop        InsidePosition     = "" // inside is the default
	InsideBottom     InsidePosition     = "outside"
)
View Source
const (
	// 1 point = 25.4/72 mm (exact: 1/72 inch = 25.4mm/72)
	PointsToMM = 25.4 / 72.0
	// 1 mm = 72/25.4 points (exact reciprocal)
	MMToPoints = 72.0 / 25.4
	// 1 rem = 12 points (common web default)
	RemToPoints = 12.0
	// 1 rem = 4.233333... mm (12pt converted to mm)
	RemToMM = RemToPoints * PointsToMM
)

Unit conversion constants

Variables

This section is empty.

Functions

func Close

func Close() error

Close closes any converters that need cleanup (like Playwright)

func Convert

func Convert(ctx context.Context, svgPath, outputPath string, options *ConvertOptions) error

Convert converts an SVG file using the best available converter

func ConvertPDFToPNG

func ConvertPDFToPNG(pdfData []byte, outputPath string, dpi int) error

ConvertPDFToPNG converts a PDF to PNG using Ghostscript or ImageMagick

func ConvertSVGToPDF

func ConvertSVGToPDF(svgBytes []byte) ([]byte, error)

ConvertSVGToPDF converts SVG bytes to PDF bytes

func ConvertSVGToPNG

func ConvertSVGToPNG(svgBytes []byte) ([]byte, error)

ConvertSVGToPNG converts SVG bytes to PNG bytes with aspect ratio preservation

func ConvertWithFallback

func ConvertWithFallback(ctx context.Context, svgPath, outputPath string, options *ConvertOptions) error

ConvertWithFallback attempts conversion with fallback to other converters

func ExtractSVGDimensions

func ExtractSVGDimensions(svgBytes []byte) (float64, float64, error)

ExtractSVGDimensions parses SVG content to extract width and height

func GetAvailableConverters

func GetAvailableConverters() []string

GetAvailableConverters returns a list of available converter names

func GetPreferred

func GetPreferred() string

GetPreferred returns the preferred converter name

func GetSupportedFormats

func GetSupportedFormats() []string

GetSupportedFormats returns all formats supported by at least one converter

func NewConverterError

func NewConverterError(converter, operation string, err error) error

NewConverterError creates a new converter error

func SaveAnalysisDebugImage

func SaveAnalysisDebugImage(imagePath, outputPath string, result *LayoutAnalysisResult) error

SaveAnalysisDebugImage saves a debug version of the image with column boundaries marked

func SetPreferred

func SetPreferred(name string) error

SetPreferred sets the preferred converter by name

Types

type Bounds

type Bounds struct {
	X      int `json:"x"`
	Y      int `json:"y"`
	Width  int `json:"width"`
	Height int `json:"height"`
}

Bounds represents a rectangular area

type Box

type Box struct {
	api.Rectangle
	Borders *api.Borders
	Labels  []Label
	Lines   []Line
}

func NewBorderedBox

func NewBorderedBox(width, height int, borderColor api.Color, label ...string) Box

NewBorderedBox creates a box with borders and optional label

func NewCardBox

func NewCardBox(width, height int, title string, borderColor api.Color) Box

NewCardBox creates a card-style box with border and title

func NewSimpleBox

func NewSimpleBox(width, height int, label ...string) Box

NewSimpleBox creates a simple box with dimensions and optional label

func NewTitledBox

func NewTitledBox(width, height int, title string) Box

NewTitledBox creates a box with a title label at the top

type BoxBuilder

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

BoxBuilder provides a fluent API for creating Box instances

func NewBoxBuilder

func NewBoxBuilder() *BoxBuilder

NewBoxBuilder creates a new BoxBuilder

func (*BoxBuilder) AddLabel

func (b *BoxBuilder) AddLabel(label Label) *BoxBuilder

AddLabel adds a pre-built Label to the box

func (*BoxBuilder) AddLine

func (b *BoxBuilder) AddLine(line Line) *BoxBuilder

AddLine adds a line to the box

func (*BoxBuilder) Build

func (b *BoxBuilder) Build() Box

Build creates and returns the Box instance

func (*BoxBuilder) WithBorder

func (b *BoxBuilder) WithBorder(line api.Line) *BoxBuilder

WithBorder sets all borders to the same line style

func (*BoxBuilder) WithBorderColor

func (b *BoxBuilder) WithBorderColor(color api.Color) *BoxBuilder

WithBorderColor sets all borders to the same color with default width

func (*BoxBuilder) WithBorders

func (b *BoxBuilder) WithBorders(borders *api.Borders) *BoxBuilder

WithBorders sets the borders of the box

func (*BoxBuilder) WithLabel

func (b *BoxBuilder) WithLabel(label string, positionOrStyle ...string) *BoxBuilder

WithLabel adds a label to the box using variadic parameters First parameter is the label text Additional parameters can be position ("top-left") or styles ("font-bold")

func (*BoxBuilder) WithLabels

func (b *BoxBuilder) WithLabels(labels []Label) *BoxBuilder

WithLabels sets multiple labels at once

func (*BoxBuilder) WithLines

func (b *BoxBuilder) WithLines(lines []Line) *BoxBuilder

WithLines sets multiple lines at once

func (*BoxBuilder) WithRectangle

func (b *BoxBuilder) WithRectangle(rect api.Rectangle) *BoxBuilder

WithRectangle sets the rectangle dimensions using an api.Rectangle

func (*BoxBuilder) WithSize

func (b *BoxBuilder) WithSize(width, height int) *BoxBuilder

WithSize sets the width and height of the box

type ChildBox

type ChildBox struct {
	Box SVGBox  // The child box
	X   float64 // X position on parent
	Y   float64 // Y position on parent
}

ChildBox represents a box positioned within another box

type ChromiumConverter

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

ChromiumConverter implements SVGConverter using Chrome/Chromium headless mode

func NewChromiumConverter

func NewChromiumConverter() *ChromiumConverter

NewChromiumConverter creates a new Chromium converter

func (*ChromiumConverter) Convert

func (c *ChromiumConverter) Convert(ctx context.Context, svgPath, outputPath string, options *ConvertOptions) error

Convert converts an SVG file using Chrome/Chromium headless mode

func (*ChromiumConverter) ConvertToFormat

func (c *ChromiumConverter) ConvertToFormat(ctx context.Context, svgPath, format string, options *ConvertOptions) (string, error)

ConvertToFormat is a convenience method that determines output path based on format

func (*ChromiumConverter) GetChromePath

func (c *ChromiumConverter) GetChromePath() string

GetChromePath returns the detected Chrome path (for testing/debugging)

func (*ChromiumConverter) IsAvailable

func (c *ChromiumConverter) IsAvailable() bool

IsAvailable checks if Chrome/Chromium is available on the system

func (*ChromiumConverter) Name

func (c *ChromiumConverter) Name() string

Name returns the name of this converter

func (*ChromiumConverter) SupportedFormats

func (c *ChromiumConverter) SupportedFormats() []string

SupportedFormats returns formats supported by Chrome/Chromium

type Circle

type Circle struct {
	Positionable
	api.Circle
	Labels []Label
}

type CircleShape

type CircleShape struct {
	X        float64
	Y        float64
	Diameter float64
	Depth    float64
	Label    string
}

CircleShape represents a circular shape in the box

type ConvertOptions

type ConvertOptions struct {
	// Output format (png, jpg, jpeg, pdf, eps, ps)
	Format string

	// Output width in pixels (0 = auto)
	Width int

	// Output height in pixels (0 = auto)
	Height int

	// DPI for raster formats (0 = default)
	DPI int

	// Background color (transparent if empty)
	BackgroundColor string

	// Quality for JPEG (0-100, 0 = default)
	Quality int
}

ConvertOptions holds options for SVG conversion

func DefaultConvertOptions

func DefaultConvertOptions() *ConvertOptions

DefaultConvertOptions returns default conversion options

type ConverterError

type ConverterError struct {
	Converter string
	Operation string
	Err       error
}

ConverterError represents an error from a converter

func (*ConverterError) Error

func (e *ConverterError) Error() string

func (*ConverterError) Unwrap

func (e *ConverterError) Unwrap() error

type ConverterType

type ConverterType string

ConverterType represents the type of SVG converter

const (
	ConverterTypeInkscape   ConverterType = "inkscape"
	ConverterTypeRSVG       ConverterType = "rsvg"
	ConverterTypeChromium   ConverterType = "chromium"
	ConverterTypePlaywright ConverterType = "playwright"
)

type Cut

type Cut struct {
	Orientation string // "horizontal" or "vertical"
	Position    float64
	Width       float64
	Depth       float64
	Label       string
}

Cut represents a rectangular cut in the box

type EdgeCut

type EdgeCut struct {
	Edge  string // "left", "right", "top", "bottom"
	Width float64
	Depth float64
	Label string
}

EdgeCut represents a cut along an edge of the box

type FontSize

type FontSize Point

FontSize represents a font size in points (standard unit for typography)

func NewFontSize

func NewFontSize(value float64) FontSize

NewFontSize creates a new FontSize value

func (FontSize) Float64

func (f FontSize) Float64() float64

Float64 returns the font size as a float64 in points

func (FontSize) LineHeight

func (f FontSize) LineHeight(multiplier float64) MM

LineHeight calculates line height with a given multiplier

func (FontSize) String

func (f FontSize) String() string

String returns a formatted string representation

func (FontSize) ToMM

func (f FontSize) ToMM() MM

ToMM converts font size to millimeters for layout calculations

type HorizontalPosition

type HorizontalPosition string

type InkscapeConverter

type InkscapeConverter struct{}

InkscapeConverter implements SVGConverter using Inkscape

func NewInkscapeConverter

func NewInkscapeConverter() *InkscapeConverter

NewInkscapeConverter creates a new Inkscape converter

func (*InkscapeConverter) Convert

func (c *InkscapeConverter) Convert(ctx context.Context, svgPath, outputPath string, options *ConvertOptions) error

Convert converts an SVG file using Inkscape

func (*InkscapeConverter) ConvertToFormat

func (c *InkscapeConverter) ConvertToFormat(ctx context.Context, svgPath, format string, options *ConvertOptions) (string, error)

ConvertToFormat is a convenience method that determines output path based on format

func (*InkscapeConverter) IsAvailable

func (c *InkscapeConverter) IsAvailable() bool

IsAvailable checks if Inkscape is available in PATH

func (*InkscapeConverter) Name

func (c *InkscapeConverter) Name() string

Name returns the name of this converter

func (*InkscapeConverter) SupportedFormats

func (c *InkscapeConverter) SupportedFormats() []string

SupportedFormats returns formats supported by Inkscape

type InsidePosition

type InsidePosition string

type Label

type Label struct {
	Positionable
	api.Text
}

type LabelBounds

type LabelBounds struct {
	X      float64
	Y      float64
	Width  float64
	Height float64
	Label  *Label
}

LabelBounds represents the rectangular bounds of a label

type LabelPosition

type LabelPosition struct {
	Vertical   VerticalPosition
	Horizontal HorizontalPosition
	Inside     InsidePosition
}

func ParsePosition

func ParsePosition(s string) LabelPosition

ParsePosition parses position strings like "center", "top-left", "bottom-right-outside"

type LayoutAnalysisResult

type LayoutAnalysisResult struct {
	PageWidth           int      `json:"page_width"`
	PageHeight          int      `json:"page_height"`
	LeftColumnBounds    *Bounds  `json:"left_column_bounds"`
	RightColumnBounds   *Bounds  `json:"right_column_bounds"`
	LeftColumnWidth     int      `json:"left_column_width"`
	RightColumnWidth    int      `json:"right_column_width"`
	LeftColumnRatio     float64  `json:"left_column_ratio"`
	RightColumnRatio    float64  `json:"right_column_ratio"`
	HasSideBySideLayout bool     `json:"has_side_by_side_layout"`
	LayoutValid         bool     `json:"layout_valid"`
	ValidationErrors    []string `json:"validation_errors"`
}

LayoutAnalysisResult contains the results of analyzing a PDF layout

func AnalyzeImageLayout

func AnalyzeImageLayout(imagePath string, targetLeftRatio, targetRightRatio float64) (*LayoutAnalysisResult, error)

AnalyzeImageLayout analyzes a PNG image to determine layout structure

func AnalyzePDFLayout

func AnalyzePDFLayout(pdfData []byte, targetLeftRatio, targetRightRatio float64) (*LayoutAnalysisResult, error)

AnalyzePDFLayout converts a PDF to PNG and analyzes its layout structure

type Line

type Line struct {
	Positionable
	api.Line
	Labels []Label
}

type MM

type MM float64

MM represents a measurement in millimeters

func NewMM

func NewMM(value float64) MM

NewMM creates a new MM value

func (MM) Add

func (m MM) Add(other MM) MM

Add adds two MM values

func (MM) Float64

func (m MM) Float64() float64

Float64 returns the mm value as a float64

func (MM) Multiply

func (m MM) Multiply(factor float64) MM

Multiply multiplies an MM by a scalar

func (MM) String

func (m MM) String() string

String returns a formatted string representation

func (MM) ToPoints

func (m MM) ToPoints() Point

ToPoints converts millimeters to points

type MeasureLine

type MeasureLine struct {
	X1         float64
	Y1         float64
	X2         float64
	Y2         float64
	Label      string
	Offset     float64 // Distance from the measured object
	ShowArrows bool
	Style      string // "solid" or "dashed"
}

MeasureLine represents a dimension line with arrows and label

type PaddingBox

type PaddingBox struct {
	Top    float64
	Right  float64
	Bottom float64
	Left   float64
}

PaddingBox represents padding for all four sides

type PlaywrightConverter

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

PlaywrightConverter implements SVGConverter using Playwright

func NewPlaywrightConverter

func NewPlaywrightConverter() *PlaywrightConverter

NewPlaywrightConverter creates a new Playwright converter

func (*PlaywrightConverter) Close

func (c *PlaywrightConverter) Close() error

Close closes the browser and Playwright instance

func (*PlaywrightConverter) Convert

func (c *PlaywrightConverter) Convert(ctx context.Context, svgPath, outputPath string, options *ConvertOptions) error

Convert converts an SVG file using Playwright

func (*PlaywrightConverter) ConvertToFormat

func (c *PlaywrightConverter) ConvertToFormat(ctx context.Context, svgPath, format string, options *ConvertOptions) (string, error)

ConvertToFormat is a convenience method that determines output path based on format

func (*PlaywrightConverter) IsAvailable

func (c *PlaywrightConverter) IsAvailable() bool

IsAvailable checks if Playwright is available (lazy initialization)

func (*PlaywrightConverter) Name

func (c *PlaywrightConverter) Name() string

Name returns the name of this converter

func (*PlaywrightConverter) SupportedFormats

func (c *PlaywrightConverter) SupportedFormats() []string

SupportedFormats returns formats supported by Playwright

type Point

type Point float64

Point represents a measurement in typographic points

func NewPoint

func NewPoint(value float64) Point

NewPoint creates a new Point value

func (Point) Add

func (p Point) Add(other Point) Point

Add adds two Point values

func (Point) Float64

func (p Point) Float64() float64

Float64 returns the point value as a float64

func (Point) Multiply

func (p Point) Multiply(factor float64) Point

Multiply multiplies a Point by a scalar

func (Point) String

func (p Point) String() string

String returns a formatted string representation

func (Point) ToMM

func (p Point) ToMM() MM

ToMM converts points to millimeters

type Positionable

type Positionable struct {
	Position *LabelPosition
	// If both position and absolute is provided, absolute is relative to position
	Absolute *api.Position
}

type PositionedLabel

type PositionedLabel struct {
	Label  Label
	X      int
	Y      int
	Anchor string
	Bounds LabelBounds
}

PositionedLabel represents a label with calculated position

type RSVGConverter

type RSVGConverter struct{}

RSVGConverter implements SVGConverter using rsvg-convert

func NewRSVGConverter

func NewRSVGConverter() *RSVGConverter

NewRSVGConverter creates a new RSVG converter

func (*RSVGConverter) Convert

func (c *RSVGConverter) Convert(ctx context.Context, svgPath, outputPath string, options *ConvertOptions) error

Convert converts an SVG file using rsvg-convert

func (*RSVGConverter) ConvertToFormat

func (c *RSVGConverter) ConvertToFormat(ctx context.Context, svgPath, format string, options *ConvertOptions) (string, error)

ConvertToFormat is a convenience method that determines output path based on format

func (*RSVGConverter) IsAvailable

func (c *RSVGConverter) IsAvailable() bool

IsAvailable checks if rsvg-convert is available in PATH

func (*RSVGConverter) Name

func (c *RSVGConverter) Name() string

Name returns the name of this converter

func (*RSVGConverter) SupportedFormats

func (c *RSVGConverter) SupportedFormats() []string

SupportedFormats returns formats supported by rsvg-convert

type Rem

type Rem float64

Rem represents a measurement in CSS rem units

func NewRem

func NewRem(value float64) Rem

NewRem creates a new Rem value

func (Rem) Add

func (r Rem) Add(other Rem) Rem

Add adds two Rem values

func (Rem) Float64

func (r Rem) Float64() float64

Float64 returns the rem value as a float64

func (Rem) Multiply

func (r Rem) Multiply(factor float64) Rem

Multiply multiplies a Rem by a scalar

func (Rem) String

func (r Rem) String() string

String returns a formatted string representation

func (Rem) ToFontSize

func (r Rem) ToFontSize() FontSize

ToFontSize converts rem to FontSize (assuming rem is used for font sizing)

func (Rem) ToMM

func (r Rem) ToMM() MM

ToMM converts rem to millimeters

func (Rem) ToPoints

func (r Rem) ToPoints() Point

ToPoints converts rem to points

type SVGBox

type SVGBox struct {
	api.Box                  // Inherits Rectangle, Fill, Border, Padding
	Labels                   []Label
	Lines                    []SVGLine
	Circles                  []CircleShape
	Cuts                     []Cut
	EdgeCuts                 []EdgeCut
	MeasureLines             []MeasureLine
	ChildBoxes               []ChildBox // Nested boxes positioned on this box
	ShowDimensions           bool
	DimensionUnit            string
	ActualWidth              float64
	ActualHeight             float64
	SVGPadding               float64 // Padding for the SVG canvas
	EnableCollisionAvoidance bool    // Enable automatic collision avoidance
	YAxisUp                  bool    // True for bottom-up (CNC/CAD), false for top-down (SVG default)
}

SVGBox generates an SVG representation of a box with labels and borders

func NewLayoutBox

func NewLayoutBox(width, height int, title string) SVGBox

NewLayoutBox creates an SVG box for layout diagrams with child boxes

func NewSimpleSVGBox

func NewSimpleSVGBox(width, height int, label ...string) SVGBox

NewSimpleSVGBox creates a simple SVG box with dimensions and optional label

func NewTechnicalDrawing

func NewTechnicalDrawing(width, height int) SVGBox

NewTechnicalDrawing creates an SVG box for technical drawings

func NewWoodworkingBox

func NewWoodworkingBox(width, height int, actualWidth, actualHeight float64) SVGBox

NewWoodworkingBox creates an SVG box suitable for woodworking diagrams

func (SVGBox) GenerateSVG

func (b SVGBox) GenerateSVG() ([]byte, error)

GenerateSVG creates an SVG representation of the box

func (SVGBox) Nodes

func (b SVGBox) Nodes() string

Nodes generates the SVG nodes without the outer <svg> wrapper

func (SVGBox) SaveTo

func (b SVGBox) SaveTo(path string) error

type SVGBoxBuilder

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

SVGBoxBuilder provides a fluent API for creating SVGBox instances

func NewSVGBoxBuilder

func NewSVGBoxBuilder() *SVGBoxBuilder

NewSVGBoxBuilder creates a new SVGBoxBuilder with sensible defaults

func (*SVGBoxBuilder) AddChildBox

func (b *SVGBoxBuilder) AddChildBox(child ChildBox) *SVGBoxBuilder

AddChildBox adds a child box at the specified position

func (*SVGBoxBuilder) AddChildBoxAt

func (b *SVGBoxBuilder) AddChildBoxAt(x, y float64, childBox SVGBox) *SVGBoxBuilder

AddChildBoxAt adds a child SVGBox at the specified coordinates

func (*SVGBoxBuilder) AddCircle

func (b *SVGBoxBuilder) AddCircle(x, y, diameter float64, label ...string) *SVGBoxBuilder

AddCircle adds a circle to the SVG box with optional label

func (*SVGBoxBuilder) AddCircleShape

func (b *SVGBoxBuilder) AddCircleShape(circle CircleShape) *SVGBoxBuilder

AddCircleShape adds a pre-built CircleShape to the SVG box

func (*SVGBoxBuilder) AddCut

func (b *SVGBoxBuilder) AddCut(orientation string, position, width, depth float64, label ...string) *SVGBoxBuilder

AddCut adds a cut to the SVG box with optional label

func (*SVGBoxBuilder) AddEdgeCut

func (b *SVGBoxBuilder) AddEdgeCut(edge string, width, depth float64, label ...string) *SVGBoxBuilder

AddEdgeCut adds an edge cut to the SVG box with optional label

func (*SVGBoxBuilder) AddLabel

func (b *SVGBoxBuilder) AddLabel(label Label) *SVGBoxBuilder

AddLabel adds a pre-built Label to the SVG box

func (*SVGBoxBuilder) AddLine

func (b *SVGBoxBuilder) AddLine(x1, y1, x2, y2 float64, styles ...string) *SVGBoxBuilder

AddLine adds a line to the SVG box with coordinates and optional styles

func (*SVGBoxBuilder) AddMeasureLine

func (b *SVGBoxBuilder) AddMeasureLine(x1, y1, x2, y2 float64, label string, options ...string) *SVGBoxBuilder

AddMeasureLine adds a measure line to the SVG box

func (*SVGBoxBuilder) AddSVGLine

func (b *SVGBoxBuilder) AddSVGLine(line SVGLine) *SVGBoxBuilder

AddSVGLine adds a pre-built SVGLine to the SVG box

func (*SVGBoxBuilder) Build

func (b *SVGBoxBuilder) Build() SVGBox

Build creates and returns the SVGBox instance

func (*SVGBoxBuilder) WithActualSize

func (b *SVGBoxBuilder) WithActualSize(width, height float64) *SVGBoxBuilder

WithActualSize sets the actual physical dimensions (for dimension display)

func (*SVGBoxBuilder) WithCollisionAvoidance

func (b *SVGBoxBuilder) WithCollisionAvoidance(enable bool) *SVGBoxBuilder

WithCollisionAvoidance enables/disables automatic label collision avoidance

func (*SVGBoxBuilder) WithFill

func (b *SVGBoxBuilder) WithFill(color api.Color) *SVGBoxBuilder

WithFill sets the fill color of the SVG box

func (*SVGBoxBuilder) WithLabel

func (b *SVGBoxBuilder) WithLabel(text, position string, styles ...string) *SVGBoxBuilder

func (*SVGBoxBuilder) WithPadding

func (b *SVGBoxBuilder) WithPadding(padding api.Padding) *SVGBoxBuilder

WithPadding sets the padding of the SVG box

func (*SVGBoxBuilder) WithSVGPadding

func (b *SVGBoxBuilder) WithSVGPadding(padding float64) *SVGBoxBuilder

WithSVGPadding sets the SVG canvas padding

func (*SVGBoxBuilder) WithShowDimensions

func (b *SVGBoxBuilder) WithShowDimensions(show bool, unit ...string) *SVGBoxBuilder

WithShowDimensions enables/disables dimension display with optional unit

func (*SVGBoxBuilder) WithSize

func (b *SVGBoxBuilder) WithSize(width, height int) *SVGBoxBuilder

WithSize sets the width and height of the SVG box

func (*SVGBoxBuilder) WithStyle

func (b *SVGBoxBuilder) WithStyle(styles ...string) *SVGBoxBuilder

WithStyle applies Tailwind-style classes to the SVG box, including border parsing

func (*SVGBoxBuilder) WithYAxisUp

func (b *SVGBoxBuilder) WithYAxisUp(up bool) *SVGBoxBuilder

WithYAxisUp sets the Y-axis direction (true for bottom-up like CAD, false for top-down like SVG)

type SVGConverter

type SVGConverter interface {
	// Name returns the name of the converter
	Name() string

	// IsAvailable checks if the converter is available on the system
	IsAvailable() bool

	// SupportedFormats returns the list of output formats this converter supports
	SupportedFormats() []string

	// Convert converts an SVG file to the specified format
	Convert(ctx context.Context, svgPath, outputPath string, options *ConvertOptions) error
}

SVGConverter defines the interface for converting SVG files to other formats

func GetConverter

func GetConverter(name string) (SVGConverter, error)

GetConverter returns a converter by name

type SVGConverterManager

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

SVGConverterManager manages multiple SVG converters with fallback support

func NewSVGConverterManager

func NewSVGConverterManager() *SVGConverterManager

NewSVGConverterManager creates a new converter manager

func (*SVGConverterManager) GetBestConverter

func (m *SVGConverterManager) GetBestConverter(format string) (SVGConverter, error)

GetBestConverter returns the best available converter for the given format

type SVGLine

type SVGLine struct {
	X1   float64  // Start X coordinate
	Y1   float64  // Start Y coordinate
	X2   float64  // End X coordinate
	Y2   float64  // End Y coordinate
	Line api.Line // Styling information
}

SVGLine represents a geometric line with coordinates and styling

type SVGWidget

type SVGWidget struct {
	SVGBox SVGBox   `json:"svg_box"`
	Height *float64 `json:"height,omitempty"`
}

SVGWidget renders an SVGBox as a widget in the PDF

func NewSVGWidget

func NewSVGWidget(svgBox SVGBox) *SVGWidget

NewSVGWidget creates a new SVG widget from an SVGBox

func (*SVGWidget) WithHeight

func (w *SVGWidget) WithHeight(height float64) *SVGWidget

WithHeight sets the height of the SVG widget in mm

type VerticalPosition

type VerticalPosition string

Jump to

Keyboard shortcuts

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