@@ -11,13 +11,15 @@ import type { EllipseProps } from "../registry/ellipse";
1111import type { LineProps } from "../registry/line" ;
1212import type { ImageProps } from "../registry/image" ;
1313import type { Barcode1DProps } from "../registry/barcode1d" ;
14+ import type { Gs1DatabarProps } from "../registry/gs1databar" ;
1415import type { Pdf417Props } from "../registry/pdf417" ;
1516import type { SerialProps } from "../registry/serial" ;
1617import { isZplRotation , type ZplRotation } from "../registry/rotation" ;
1718import type { AztecProps } from "../registry/aztec" ;
1819import type { MicroPdf417Props } from "../registry/micropdf417" ;
1920import type { CodablockProps } from "../registry/codablock" ;
2021import { putImage } from "./imageCache" ;
22+ import { GS1_DATABAR_DEFAULT_SEGMENTS } from "./gs1" ;
2123
2224/**
2325 * Categorised import report produced alongside the parsed objects.
@@ -215,6 +217,8 @@ export function parseZPL(zpl: string, dpmm = 8): ParsedZPL {
215217 let bcInterp = true ;
216218 let bcCheck = false ;
217219 let bcRotation : ZplRotation = "N" ;
220+ let gsSymbology : Gs1DatabarProps [ "symbology" ] = 1 ;
221+ let gsSegments : number | undefined = undefined ;
218222 // ^BY barcode defaults
219223 let byModuleWidth = 2 ;
220224 let byHeight = 0 ; // 0 = no ^BY height; barcode handlers use ||100 as sentinel
@@ -440,7 +444,6 @@ export function parseZPL(zpl: string, dpmm = 8): ParsedZPL {
440444 case "logmars" :
441445 case "msi" :
442446 case "plessey" :
443- case "gs1databar" :
444447 case "planet" :
445448 case "postal" :
446449 objects . push (
@@ -461,6 +464,24 @@ export function parseZPL(zpl: string, dpmm = 8): ParsedZPL {
461464 ) ,
462465 ) ;
463466 break ;
467+ case "gs1databar" :
468+ objects . push (
469+ makeObj (
470+ "gs1databar" ,
471+ x ,
472+ y ,
473+ {
474+ content,
475+ moduleWidth : byModuleWidth ,
476+ symbology : gsSymbology ,
477+ segments : gsSegments ,
478+ rotation : bcRotation ,
479+ } satisfies Gs1DatabarProps ,
480+ posType ,
481+ comment ,
482+ ) ,
483+ ) ;
484+ break ;
464485 case "pdf417" :
465486 objects . push (
466487 makeObj (
@@ -691,12 +712,13 @@ export function parseZPL(zpl: string, dpmm = 8): ParsedZPL {
691712 bcInterp = ( p [ 3 ] ?? "Y" ) === "Y" ;
692713 } ,
693714 // GS1 Databar: different param layout, also updates byModuleWidth
694- // ^BRN ,{symbology},{magnification},{separator},{height},{segments}
715+ // ^BRo ,{symbology},{magnification},{separator},{height},{segments}
695716 BR ( p ) {
696717 fieldType = "gs1databar" ;
697718 bcRotation = readRotation ( p [ 0 ] ) ;
698- bcHeight = int ( p [ 4 ] , byHeight || 100 ) ;
699719 byModuleWidth = int ( p [ 2 ] , byModuleWidth ) ;
720+ gsSymbology = ( int ( p [ 1 ] , 1 ) as Gs1DatabarProps [ "symbology" ] ) || 1 ;
721+ gsSegments = p [ 5 ] !== undefined ? int ( p [ 5 ] , GS1_DATABAR_DEFAULT_SEGMENTS ) : undefined ;
700722 } ,
701723
702724 // ^BQN,2,{magnification} — QR Code
0 commit comments