javascript - tcpdf 在字符串的和处生成正方形

标签 javascript php css svg tcpdf

我对 TCPDF 有疑问。我在字符串末尾得到 square。 实际上,我正在做的是使用 svg 图像生成 PDF

这是代码,

$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'); 

它对某些 svg 非常有用(我有很多不同字体的 svg,所以我们可以说有些字体不会生成正方形)。 这是图片

enter image description here

经过一些研究我修改了svg图像内容 来自,

<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>

为了,

<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>

它对我有用。知道那里发生了什么吗?不确定它的 svg 问题或 tcpdf

最佳答案

SVG没有问题,肯定是TCPDF。当您尝试打印未定义的字符时,您看到的矩形是某些字体显示的内容。

因为当您删除空格时它消失了,我猜 TCPDF 正在尝试打印回车符 (13) 或其他字符。

您可能希望将错误报告给 TCPDF 人员。

关于javascript - tcpdf 在字符串的和处生成正方形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39242986/

相关文章:

javascript - "core-header-panel"Polymer 元素不显示内容 Div 中的文本

javascript - 加载javascript时如何修复流体div标签

javascript - 我的脚本没有运行。我使用了错误的版本吗?

php - MySQL 查询中的点 (.) 应该做什么?

php - 具有多个过滤器的 mySQL 搜索语句

php - 为什么链接的顶部和底部有空白?

javascript - Angular : Directive updating parent scope inside of ng-repeat

javascript - 点击事件在backbone.js中不起作用

javascript - PHP 根据下拉列表获取文本框中子数组的值

javascript - 有没有办法编辑WebComponent的CSS/JS?