File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -77,8 +77,7 @@ protected function header():string{
77
77
$ height = ($ this ->options ->svgHeight !== null ) ? sprintf (' height="%s" ' , $ this ->options ->svgHeight ) : '' ;
78
78
79
79
/** @noinspection HtmlUnknownAttribute */
80
- return sprintf (
81
- '<?xml version="1.0" encoding="UTF-8"?>%6$s ' .
80
+ $ header = sprintf (
82
81
'<svg xmlns="http://www.w3.org/2000/svg" class="qr-svg %1$s" viewBox="0 0 %2$s %2$s" preserveAspectRatio="%3$s"%4$s%5$s>%6$s ' ,
83
82
$ this ->options ->cssClass ,
84
83
($ this ->options ->svgViewBoxSize ?? $ this ->moduleCount ),
@@ -87,6 +86,12 @@ protected function header():string{
87
86
$ height ,
88
87
$ this ->options ->eol
89
88
);
89
+
90
+ if ($ this ->options ->svgAddXmlHeader ){
91
+ $ header = sprintf ('<?xml version="1.0" encoding="UTF-8"?>%s%s ' , $ this ->options ->eol , $ header );
92
+ }
93
+
94
+ return $ header ;
90
95
}
91
96
92
97
/**
Original file line number Diff line number Diff line change @@ -315,6 +315,13 @@ trait QROptionsTrait{
315
315
* QRMarkupSVG settings
316
316
*/
317
317
318
+ /**
319
+ * Whether to add an XML header line or not, e.g. to embed the SVG directly in HTML
320
+ *
321
+ * `<?xml version="1.0" encoding="UTF-8"?>`
322
+ */
323
+ protected bool $ svgAddXmlHeader = true ;
324
+
318
325
/**
319
326
* SVG opacity
320
327
*/
You can’t perform that action at this time.
0 commit comments