Generate PDF using svg raw data in php

為{幸葍}努か 提交于 2019-12-11 16:07:37

问题


Is it possible to generate pdf using svg raw data (getting from fabric js) on php side?

I have searched a bit and found this example:

https://tcpdf.org/examples/example_058/

but its except svg image not the svg raw data, so how one can generate pdf using svg raw data on server side using php?


回答1:


Just pass your svg raw data to ImageSVG

$svgRaw = '<svg height="80" width="300">
  <g fill="none">
    <path stroke="red" d="M5 20 l215 0" />
    <path stroke="black" d="M5 40 l215 0" />
    <path stroke="blue" d="M5 60 l215 0" />
  </g>
  Sorry, your browser does not support inline SVG.
</svg>';


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

$pdf->Write(0, $txt='', '', 0, 'L', true, 0, false, false, 0);


来源:https://stackoverflow.com/questions/47449692/generate-pdf-using-svg-raw-data-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!