Documentation
¶
Overview ¶
Funciones para generar códigos de barras 1D en formato SVG.
Se han seguido las mismas reglas de generación que usan las impresoras ESC/POS en el comando GS k, consultar https://download4.epson.biz/sec_pubs/pos/reference_en/escpos/gs_lk.html
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBarcodeBARS ¶
Genera la secuencia de módulos de las barras de código:
- code: código a representar
- kind: tipo de código de barras
Example ¶
package main import ( "fmt" "github.com/horus-es/go-util/v2/barcode" ) func main() { bars, hri, _ := barcode.GetBarcodeBARS("123456", barcode.C128X) fmt.Printf("%s: %s\n", hri, bars) }
Output: 123456: 2112321122321311233311211321312331112
func GetBarcodeSVG ¶
func GetBarcodeSVG(code string, kind KIND, w, h float64, color string, hri HRI, inline bool) (string, error)
Genera un documento SVG:
- code: código a representar
- kind: tipo de código de barras
- w: ancho del módulo
- h: altura del código, incluye texto HRI
- hri: posición del texto HRI
- inline: suprime cabeceras SVG para embeber en HTML
Example ¶
package main import ( "fmt" "github.com/horus-es/go-util/v2/barcode" ) func main() { svg, _ := barcode.GetBarcodeSVG("123456", barcode.C128X, 2, 100, "#000", barcode.Below, false) fmt.Print(svg) }
Output: <?xml version="1.0" standalone="no" ?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="156.00000" height="116.00000" version="1.1" xmlns="http://www.w3.org/2000/svg"> <g fill="#000" stroke="none"> <rect x="10.00000" y="0.00000" width="4.00000" height="100.00000" /> <rect x="16.00000" y="0.00000" width="2.00000" height="100.00000" /> <rect x="22.00000" y="0.00000" width="6.00000" height="100.00000" /> <rect x="32.00000" y="0.00000" width="2.00000" height="100.00000" /> <rect x="36.00000" y="0.00000" width="4.00000" height="100.00000" /> <rect x="44.00000" y="0.00000" width="6.00000" height="100.00000" /> <rect x="54.00000" y="0.00000" width="2.00000" height="100.00000" /> <rect x="62.00000" y="0.00000" width="2.00000" height="100.00000" /> <rect x="66.00000" y="0.00000" width="4.00000" height="100.00000" /> <rect x="76.00000" y="0.00000" width="6.00000" height="100.00000" /> <rect x="88.00000" y="0.00000" width="2.00000" height="100.00000" /> <rect x="92.00000" y="0.00000" width="4.00000" height="100.00000" /> <rect x="98.00000" y="0.00000" width="2.00000" height="100.00000" /> <rect x="106.00000" y="0.00000" width="4.00000" height="100.00000" /> <rect x="112.00000" y="0.00000" width="6.00000" height="100.00000" /> <rect x="120.00000" y="0.00000" width="4.00000" height="100.00000" /> <rect x="130.00000" y="0.00000" width="6.00000" height="100.00000" /> <rect x="138.00000" y="0.00000" width="2.00000" height="100.00000" /> <rect x="142.00000" y="0.00000" width="4.00000" height="100.00000" /> <text x="78.00000" text-anchor="middle" dominant-baseline="hanging" y="102.00000" fill="#000" font-size="15px">123456</text> </g> </svg>
Types ¶
Click to show internal directories.
Click to hide internal directories.