Documentation
¶
Overview ¶
Package render provides image rendering capabilities for ZPL labels. It converts ZPL Label objects to bitmap images that approximate what a Zebra printer would produce.
Index ¶
- type Renderer
- func (r *Renderer) Render(label *zpl.Label) (image.Image, error)
- func (r *Renderer) RenderAll(labels []*zpl.Label) ([]image.Image, error)
- func (r *Renderer) RenderJPEG(label *zpl.Label, w io.Writer, quality int) error
- func (r *Renderer) RenderPNG(label *zpl.Label, w io.Writer) error
- func (r *Renderer) WithIgnoreLabelHome(ignore bool) *Renderer
- func (r *Renderer) WithSize(width, height int) *Renderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Renderer ¶
type Renderer struct {
// DPI is the printer resolution (203, 300, or 600 dots per inch).
DPI zpl.DPI
// Width is the label width in dots. If zero, uses the label's configured width.
Width int
// Height is the label height in dots. If zero, uses the label's configured height.
Height int
// IgnoreLabelHome controls whether ^LH (label home) offsets are applied.
// When false (default), offsets are applied exactly as a printer would.
// When true, offsets are ignored for cleaner previews.
IgnoreLabelHome bool
}
Renderer holds configuration for rendering ZPL labels to images.
func New ¶
New creates a new Renderer with the given DPI. Width and height will be taken from the label if not set.
func (*Renderer) Render ¶
Render converts a Label to an image. The returned image uses white background with black elements, matching thermal label printer output.
func (*Renderer) RenderJPEG ¶
RenderJPEG renders the label and writes it as a JPEG image to the writer. Quality should be between 1 and 100, where 100 is best quality.
func (*Renderer) RenderPNG ¶
RenderPNG renders the label and writes it as a PNG image to the writer.
func (*Renderer) WithIgnoreLabelHome ¶
WithIgnoreLabelHome sets whether to ignore ^LH label home offsets. When false (default), offsets are applied exactly as a printer would. When true, offsets are ignored for cleaner previews.