@@ -15,12 +15,21 @@ class SVGRenderer{
1515 var currentX = this . options . marginLeft ;
1616
1717 this . prepareSVG ( ) ;
18+
19+ // Create Background
20+ if ( ! this . options . background . match ( / t r a n s p a r e n t | # [ a - f \d ] { 3 } (?: [ a - f \d ] { 3 } ) ? 0 / i) ) {
21+ this . drawRect ( 0 , 0 , "100%" , "100%" , this . svg ) . setAttribute ( "fill" , this . options . background ) ;
22+ }
23+
1824 for ( let i = 0 ; i < this . encodings . length ; i ++ ) {
1925 var encoding = this . encodings [ i ] ;
2026 var encodingOptions = merge ( this . options , encoding . options ) ;
2127
2228 var group = this . createGroup ( currentX , encodingOptions . marginTop , this . svg ) ;
23- group . setAttribute ( "fill" , encodingOptions . lineColor ) ;
29+
30+ if ( ! encodingOptions . lineColor . match ( / b l a c k | # 0 0 0 (?: 0 0 0 ) ? f ? / i) ) {
31+ group . setAttribute ( "fill" , encodingOptions . lineColor ) ;
32+ }
2433
2534 this . drawSvgBarcode ( group , encodingOptions , encoding ) ;
2635 this . drawSVGText ( group , encodingOptions , encoding ) ;
@@ -41,10 +50,6 @@ class SVGRenderer{
4150
4251 var width = totalWidth + this . options . marginLeft + this . options . marginRight ;
4352 this . setSvgAttributes ( width , maxHeight ) ;
44-
45- if ( this . options . background ) {
46- this . drawRect ( 0 , 0 , "100%" , "100%" , this . svg ) . setAttribute ( "fill" , this . options . background ) ;
47- }
4853 }
4954
5055 drawSvgBarcode ( parent , options , encoding ) {
0 commit comments