doudun8705 2016-04-22 10:37
浏览 246

TCPDF SVG无法显示

I am trying to generate a document (this part works correctly) that must have a logo in the top right corner (this does not work).

What is the problem with my code here? I double checked the file exists and is readable. Tried to move things around, googled usage examples, but still stuck with TCPDF silently not displaying the image.

$generator = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set header and footer fonts
$generator->setPrintHeader(false);
$generator->setPrintFooter(false);
// set margins
$generator->SetMargins(10, 10, 10);


$generator->AddPage();
$generator->SetFont('helvetica', '', 8);

$generator->writeHTML($html, true, false, false, false, '');

$generator->ImageSVG(
    $file = ('path/to/my/file.svg'),
    $x = 250,
    $y = -10,
    $w = '',
    $h = 50,
    $link = '',
    $align = '',
    $palign = '',
    $border = 0,
    $fitonpage = false);

return $generator->Output('generated.pdf', 'S');
  • 写回答

1条回答 默认 最新

  • dongxie45083 2016-04-25 05:50
    关注

    Use Imagick to create a PNG directly from the SVG file and see if that opens OK:

    $im = new Imagick('path/to/my/file.svg');
    $im->setImageFormat( 'PNG24' );
    $im->writeImage('path/to/my/file.png');
    

    If that file displays OK, I'm not sure what the problem is. However, if that file doesn't display OK, then the problem may be in the underlying SVG file. Imagick is quite strict when checking attributes, etc, in the incoming SVG file, so even something quite small (eg. an attribute that shouldn't be allowed to have a null value having a null value) could cause it to fail.

    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)