MPDF不支持图像/图标旋转 [英] MPDF not supporting image/icon rotation

查看:161
本文介绍了MPDF不支持图像/图标旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的HTML脚本生成PDF.现在该脚本是

<?php

require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf();

$mpdf->WriteHTML('<div class="pageContatiner noSelect ui-droppable slctCon"><div onmousedown="objSelection(this)" ontouchstart="objSelection(this)" id="pmObj-1" class="shape obj" style="width: 136.217px; height: 136.217px; position: absolute; transform: matrix(-0.491017, -0.87115, 0.87115, -0.491017, 0, 0); margin-left: 312px; margin-top: 99px;" x="330" y="117" angle="240.59253473738065" scalex="1" scaley="1"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" height="136.2166748046875" width="136.2166748046875"><polygon class="svgObj" fill="rgba(51,122,183,1)" stroke="rgba(51,122,183,0.99)" stroke-width="1" points="96,100 50,5 4,100" width="136.2166748046875" height="136.2166748046875"></polygon></svg></div></div>');
$mpdf->Output();

?>

但是问题是这里的三角形图标没有旋转显示.

解决方案

将SVG保存到文件中,并通过支持CSS transform: rotate属性的img元素将其链接:

<img src="triangle.svg" id="pmObj-1" class="shape obj" style="transform: rotate(45deg);">

在文档中受支持的CSS 中查看详情.. >

I would like to generate a PDF from my HTML script.Now the script is

<?php

require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf();

$mpdf->WriteHTML('<div class="pageContatiner noSelect ui-droppable slctCon"><div onmousedown="objSelection(this)" ontouchstart="objSelection(this)" id="pmObj-1" class="shape obj" style="width: 136.217px; height: 136.217px; position: absolute; transform: matrix(-0.491017, -0.87115, 0.87115, -0.491017, 0, 0); margin-left: 312px; margin-top: 99px;" x="330" y="117" angle="240.59253473738065" scalex="1" scaley="1"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" height="136.2166748046875" width="136.2166748046875"><polygon class="svgObj" fill="rgba(51,122,183,1)" stroke="rgba(51,122,183,0.99)" stroke-width="1" points="96,100 50,5 4,100" width="136.2166748046875" height="136.2166748046875"></polygon></svg></div></div>');
$mpdf->Output();

?>

But the problem is here the triangle icon is showing without rotation.

解决方案

Save your SVG to a file and link it through an img element which supports CSS transform: rotate property:

<img src="triangle.svg" id="pmObj-1" class="shape obj" style="transform: rotate(45deg);">

See more on supported CSS in the documentation.

这篇关于MPDF不支持图像/图标旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆