TCPDF - SVG 属性“data-name”将被忽略

问题描述

在使用 TCPDF 创建 PDF 后,我遇到了一个小问题。
PDF 文件的创建工作没有任何问题。但是,当我尝试在 Illustrator 中检查 PDF 时,路径名不正确。

When I open the SVG directly in Illustrator,the layer is named the way I want it.,但是 when I open the PDF file in Illustrator,this is not the correct path name.。创建 PDF 后,属性 iddata-name 似乎将从路径中删除。那么,当我使用 Illustrator 打开文件时,我该怎么做才能让路径名也显示在 PDF 中?

我的 SVG 字符串看起来像这样......

<svg viewBox="0 0 600 100" xmlns="http://www.w3.org/2000/svg">
  <path id="my-layer" data-name="my-layer" fill="none" stroke-width="1" stroke="#00f" d="M600 100 60 100 0 50 60 0 600 0 600 100z"/>
</svg>

... 然后我将此代码放入我的 $svg 变量中并创建 PDF ...

$font = TCPDF_FONTS::addTTFfont(__DIR__ . '/assets/fonts/MyCustomFont.ttf','TrueTypeUnicode','',96);

$pdf = new TCPDF('L','mm',[600,100],true,'UTF-8',false);

$pdf->SetFont($font,null,false);
$pdf->SetTitle('Document');
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->SetMargins(0,true);
$pdf->SetAutopageBreak(true);
$pdf->AddPage('L',100]);
$pdf->ImageSVG('@' . $svg,$pdf->getPageWidth(),$pdf->getPageHeight(),'C',true);
$pdf->Output('document.pdf');

一切正常,只是我无法在 PDF 文件中命名 SVG 中的路径。

背景:我需要这个用于打印机或激光的 PDF。这些设备只能读取 PDF 文件,并抱怨找不到切割线的名称

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)