简体   繁体   English

TCPDF不使用imageSVG在文本文件中使用路径变量渲染点(圆圈)

[英]TCPDF not rendering dots (circles) with path variables in text file using imageSVG

I'm trying to render a HighCharts SVG with scatter dots (with or without line it is producing the same results) to a pdf file. 我正在尝试使用散点(使用或不使用行生成相同的结果)将HighCharts SVG渲染为pdf文件。 The output will draw the lines with ImageSVG(), but it does not render the dots. 输出将使用ImageSVG()绘制线条,但不会渲染点。

I've done some manual editing of the SVG file and found that ImageSVG acts like it doesn't like this rendering command: 我已经对SVG文件进行了一些手动编辑,发现ImageSVG表现得像它不喜欢这个渲染命令:

<path fill="darkblue" d="M99 188a4 4 0 1 1 0-.004z" class="highcharts-point highcharts-negative highcharts-color-0"/>

I converted it to a circle render command: 我将它转换为圆形渲染命令:

<circle cx="95" cy="188" r="4" fill="darkblue" />

And it renders in TCPDF fine. 它在TCPDF中呈现得很好。

Is there a way to make ImageSVG properly render the path command to draw the dot, or do I need to make an algorithm to do the conversion before sending the file to ImageSVG? 有没有办法让ImageSVG正确渲染路径命令来绘制点,或者我是否需要在将文件发送到ImageSVG之前制作算法来进行转换?

I am currently working on a work-around to convert all the path commands to circle commands. 我目前正致力于将所有路径命令转换为循环命令。 This appears like it will work - I don't yet have a working algorithm for this. 这似乎会起作用 - 我还没有一个有效的算法。

It also appears to get the dot to appear in the same place as the "path" command, I have to subtract 4 from the X coordinate. 它似乎也让点出现在与“path”命令相同的位置,我必须从X坐标中减去4。

I've googled to see if anyone else has ran across this problem, and searched stackoverflow but couldn't find anything. 我用谷歌搜索是否有其他人遇到过这个问题,并搜索了stackoverflow但找不到任何东西。 I've also searched for algorithms to help with the conversion, but only found people wanting to convert the other way - from circle to path. 我也搜索过算法以帮助转换,但只发现人们想要转换另一种方式 - 从圆圈到路径。

Generic code to render svg to pdf file. 将svg呈现为pdf文件的通用代码。

pdf->ImageSVG($file='plot.svg', $x=15, $y=30, $w='', $h='', $link='http://www.tcpdf.org', $align='', $palign='', $border=1, $fitonpage=false);

the highcharts svg is too large to paste so here is the relevant section: highcharts svg太大而无法粘贴,所以这里是相关部分:

    <g class="highcharts-series-group" data-z-index="3">
        <g data-z-index=".1" class="highcharts-markers highcharts-series-0 highcharts-scatter-series highcharts-color-0">
         <path fill="powderblue" d="M98 188a4 4 0 1 1 0-.004zM99 188a4 4 0 1 1 0-.004zM101 183a4 4 0 1 1 0-.004zM108 188a4 4 0 1 1 0-.004zM122 185a4 4 0 1 1 0-.004zM150 190a4 4 0 1 1 0-.004zM206 179a4 4 0 1 1 0-.004zM315 182a4 4 0 1 1 0-.004zM572 188a4 4 0 1 1 0-.004z" class="highcharts-point highcharts-negative highcharts-color-0"/>
        </g>
    </g>

If I'm just doing a scatter chart in Highcharts, the chart output is empty - there are no dots. 如果我只是在Highcharts中进行散点图,则图表输出为空 - 没有点。

If I add lines to the scatter chart, it draws the lines but not the dots. 如果我在散点图中添加线条,则会绘制线条而不是点线。 (Which also uses the path command, but the SVG renderer in TCPDF handles those fine) (也使用path命令,但TCPDF中的SVG渲染器处理那些罚款)

Here's the solution I found for this problem; 这是我为这个问题找到的解决方案;

I switched to using the mPDF library. 我转而使用mPDF库。

The code change is going to be pretty significant, but it renders overall better than using TCPDF. 代码更改将非常重要,但它总体上比使用TCPDF更好。 To render the SVG, I create the entire certification page in an HTML document, then write that with the 'WriteHTML' function built into mPDF. 为了渲染SVG,我在HTML文档中创建了整个认证页面,然后使用内置于mPDF中的“WriteHTML”函数编写它。

It renders the path command for dots, without any rendering errors. 它呈现点的路径命令,没有任何渲染错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM