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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog