SVG text parser should "push" the style for "tspan"
PHP class for PDF
Brought to you by:
nicolaasuni
if an SVG image contains text and inside the text you have a tspan item, ALL the tspans are printed at the (0,0) location of the image.
Because text and tspan tags act as containers, I suggest this modification in the startSVGElementHandler function, in the switch section (=> is added, > is changed)
// text
case 'text':
case 'tspan': {
=> array_push($this->svgstyles, $svgstyle);
// only basic support - advanced features must be implemented
$x = (isset($attribs['x'])?$this->getHTMLUnitToUnits($attribs['x'], 0, $this->svgunit, false):$this->getx()); $y = (isset($attribs['y'])?$this->getHTMLUnitToUnits($attribs['y'], 0, $this->svgunit, false):$this->gety());
and obviously adding this line (marked by =>) in the switch of the endSVGElementHandler function
// restore previous rendering mode
$this->textrendermode = $textrendermode;
$this->textstrokewidth = $textstrokewidth;
$this->svgtext = '';
$this->StopTransform();
=> array_pop($this->svgstyles);
break;
}
default: {
OK. Fixed on TCPDF 5.8.030 with some changes.