Skip to content

Commit cdaf8aa

Browse files
committed
:octocat: +QROptionsTrait::$svgAddXmlHeader
1 parent 3d894ad commit cdaf8aa

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/Output/QRMarkupSVG.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ protected function header():string{
7777
$height = ($this->options->svgHeight !== null) ? sprintf(' height="%s"', $this->options->svgHeight) : '';
7878

7979
/** @noinspection HtmlUnknownAttribute */
80-
return sprintf(
81-
'<?xml version="1.0" encoding="UTF-8"?>%6$s'.
80+
$header = sprintf(
8281
'<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',
8382
$this->options->cssClass,
8483
($this->options->svgViewBoxSize ?? $this->moduleCount),
@@ -87,6 +86,12 @@ protected function header():string{
8786
$height,
8887
$this->options->eol
8988
);
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;
9095
}
9196

9297
/**

src/QROptionsTrait.php

+7
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,13 @@ trait QROptionsTrait{
315315
* QRMarkupSVG settings
316316
*/
317317

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+
318325
/**
319326
* SVG opacity
320327
*/

0 commit comments

Comments
 (0)