Pdf SVG->;梯度失配

Pdf SVG->;梯度失配,pdf,svg,gradient,tcpdf,Pdf,Svg,Gradient,Tcpdf,我有以下几点: <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="800" height="150" viewBox="0 0 800 150" xml:space="preserve"> <linearGradient id="SVGID_0" gradientUnits="userSpaceOnUse" x1="-40

我有以下几点:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="800" height="150" viewBox="0 0 800 150" xml:space="preserve">
<linearGradient id="SVGID_0" gradientUnits="userSpaceOnUse" x1="-400" y1="-150" x2="-400" y2="0">
<stop offset="0%" style="stop-color:rgb(255,64,64);stop-opacity: 1"/>
<stop offset="100%" style="stop-color:rgb(230,57,155);stop-opacity: 1"/>
</linearGradient>
<rect x="-400" y="-75" rx="0" ry="0" width="800" height="150" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: url(#SVGID_0); fill-rule: nonzero; opacity: 1;" transform="translate(400.5 75.5)"/>
</svg>
如下图所示,渐变应用错误

基于illustrator图像,TCPDF似乎将渐变中心应用于底部边缘。如果我手动将中心移动到上边缘,则它看起来非常接近原始边缘


你知道我该怎么解决这个问题吗?

我想这是因为rect的位置。它实际上从viewbox外部开始,然后渐变和长方体都被变换。例如,长方体和渐变
x
参数都是-400。这太复杂了,我认为一些参数被
$fitonpage=true
参数取消了,或者翻译的应用方式不同:


如果删除转换,会有不同的结果吗?嗨,Danny,恐怕不会。同样的结果。如果删除gradientUnits=“userSpaceOnUse”?(然后默认为gradientUnits=“objectBoundingBox”)。恐怕也会有同样的结果。提出一个问题和/或下载源代码并修复它。谢谢你的回答。问题是我从fabricJS获得SVG,它利用了负转换值等,修改该库似乎比修复tcpdf任务更大。相关的SVG数据是2个XML节点。您可以通过中间脚本应用更改吗?或者更好地调整您的FabricJ,这样您就不会在画布之外创建元素了?
$pdf->ImageSVG($file='images/testsvg.svg', $x=0, $y=0, $w='', $h='', $align='', $palign='', $border=0, $fitonpage=true);
<linearGradient y2="150" x2="0" y1="0" x1="0" gradientUnits="userSpaceOnUse" id="SVGID_0">
<stop
       style="stop-color:#f13c73;stop-opacity:1"
       id="stop4139"
       offset="0" />
<stop
       style="stop-color:#e6399b;stop-opacity:1"
       id="stop4141"
       offset="0.40" />
</linearGradient>
<rect
     id="rect4143"
     style="opacity:1;fill:url(#SVGID_0);fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none"
     height="150"
     width="800"
     ry="0"
     rx="0"
     y="0"
     x="0" />