Himanshu Bhardiya
Himanshu Bhardiya

Reputation: 1057

tcpdf generates square at the and of string

I have an issue with TCPDF. I am getting square at the end of string. Actually what i am doing is generating PDF using svg image.

Here is the code,

$pdf = new TCPDF();
$pdf->AddPage('L', $page_format, false, false);
$pdf->ImageSVG($uploadPath, $x=16, $y=16, $w=$width+$margin, $h=$height+$margin, $link='', $align='', $palign='', $border=0, $fitonpage=false);     
$pdf->output($filename, 'D'); 

Its working great for some svg(i have many svg with different fonts, so we can say some fonts not generating square). Here is the image

enter image description here

After some research i modified svg image content From,

<g transform="translate(1189.73 792.69)">
  <text font-family="Arvo" font-size="25" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;">
     <tspan x="-100" y="7.87" fill="rgb(0, 0, 0)">Type Text Here</tspan>
  </text>
</g>

To,

<g transform="translate(1189.73 792.69)">
  <text font-family="Arvo" font-size="25" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;"><tspan x="-100" y="7.87" fill="rgb(0, 0, 0)">Type Text Here</tspan></text>
</g>

And it worked for me. Any idea what happening there? Not sure its svg issue or tcpdf.

Upvotes: 3

Views: 835

Answers (1)

Paul LeBeau
Paul LeBeau

Reputation: 101918

There is nothing wrong with the SVG, so it is definitely TCPDF. The rectangle you are seeing is what some fonts display when you try to print an undefined character.

Since it went away when you removed whitespace, I guess TCPDF is trying to print a carriage return character (13) or something.

You may wish to report the bug to the TCPDF folks.

Upvotes: 1

Related Questions