简体   繁体   English

在PDF的SVG元素中嵌入属性

[英]Embedding attributes in SVG elements in PDFs

I'm working with a client running a sign-making business who uses proprietary software-- FlexiSIGN-PRO and i-Cut . 我正在与一个使用专有软件FlexiSIGN-PROi-Cut的标牌制作客户合作。 I'm working on a custom SVG-based tool that we'll export on the server side and make work with i-Cut, which takes an image and a vector to create a sign with a face on it. 我正在开发一个基于SVG的自定义工具,该工具将在服务器端导出并与i-Cut配合使用,该工具会获取图像和矢量以创建带有面部的标志。 i-Cut takes a PDF, so I've been looking at different solutions for exporting from an SVG file to a PDF using node-based solutions (I've tried PDFKit and screen capturing with PhantomJS . Up to this point I've got it working where I can export a vector and an image on top of each other into a PDF, which can be opened up in FlexiSIGN/i-Cut. i-Cut带有PDF,因此我一直在研究使用基于节点的解决方案将SVG文件导出为PDF的不同解决方案(我尝试了PDFKitPhantomJS的屏幕捕获 。到目前为止,我已经它可以在这里将矢量和图像彼此导出为PDF,并可以在FlexiSIGN / i-Cut中打开。

However, for the client to quickly create signs, it needs to pass in a "DieColor" color name attribute, but this is a little vague and I'm not totally sure what this means in Proprietary Software Land. 但是,为了使客户快速创建标牌,需要传递“ DieColor”颜色名称属性,但这有点含糊,我不确定这在专有软件领域中的含义。 When a file is imported/exported with the correct attributes, it should look like this in the "color specs" of the FlexiSign program: 使用正确的属性导入/导出文件时,在FlexiSign程序的“颜色规格”中应如下所示:

With my PDFs, that box is missing attributes (although the magenta fill color I'm passing in is working): 对于我的PDF,该框缺少属性(尽管我传递的洋红色填充颜色有效):

So the question is, how can I export whatever attribute this might be into PDF format? 因此,问题是,如何将任何属性导出为PDF格式? It has to be possible to embed some kind of metadata, but I'm not familiar with the PDF format or how to interact with it, or what libraries will do the job. 必须可以嵌入某种元数据,但是我不熟悉PDF格式或如何与之交互,或者什么库可以完成这项工作。 Is there a better-supported PHP library I could use? 有没有我可以使用的更好支持的PHP库? I'm also looking into the possibility of using .eps, since apparently i-Cut can use that. 我也在研究使用.eps的可能性,因为显然i-Cut可以使用它。

I also recently found this link: SVG spot color and cut lines 我最近还找到了此链接: SVG专色和切割线

That has something to do with declaring a PDF colorspace, but I literally know nothing about how that works--does it have something to do with SVG ColorProfileElement ? 这与声明PDF颜色空间有关,但是我对它的工作方式一无所知-它与SVG ColorProfileElement有关吗?

Any help would be very appreciated. 任何帮助将不胜感激。 Thanks! 谢谢!

As I see it, SVG current standard doesn't support spot color declaration and you'll need customized and/or expensive SVG > PDF conversion tool to convert named SVG color to spot color in PDF. 如我所见,SVG当前标准不支持专色声明,您将需要定制和/或昂贵的SVG> PDF转换工具,以将命名的SVG颜色转换为PDF中的专色。 If the only problem with your choice of tools and PDFs produced is they don't have spot color, you can post-process PDFs. 如果选择的工具和PDF唯一的问题是它们没有专色,则可以对PDF进行后处理。 Assuming RGB magenta is not used for anything else, 假设RGB洋红色未用于其他任何用途,

$ perl -Mstrict -MCAM::PDF -we '
> sub _n { CAM::PDF::Node->new(@_) }
> @ARGV and my $doc = CAM::PDF->new($ARGV[0]) or die();
> my $r = $doc->getValue($doc->getPage(1)->{Resources});
> $r->{ColorSpace} ||= _n("dictionary", {});
> $doc->getValue($r->{ColorSpace})->{DieLine} = _n("array", [
>     (map {_n("label", $_)} qw(Separation DieLine DeviceCMYK)),
>     _n("reference", $doc->appendObject(undef, 
>         _n("object", _n("dictionary", {
>             FunctionType => _n("number", 2),
>             Domain => _n("array", [map{_n("number", $_)} (0,1)]),
>             C0 => _n("array", [map {_n("number", $_)} (0,0,0,0)]),
>             C1 => _n("array", [map {_n("number", $_)} (0,0.5,1,0.2)]),
>             N => _n("number", 1),
>         })),
>     ,0)),
> ]);
> my $s = $doc->getPageContent(1);
> $s =~ s!(?<=\s)1\s0\s1\srg(?=\s)!/DieLine cs 1 sc!g;
> $doc->setPageContent(1, $s);
> $ARGV[0] =~ s/(.pdf)$/+$1/;
> $doc->cleanoutput($ARGV[0]);
> ' test.pdf

the resultant test+.pdf should have DieLine spot color (more or less orange looking, as in example) in place of 255-0-255 filled shapes. 生成的test+.pdf应具有DieLine专色(例如,或多或少呈橙色)代替255-0-255填充形状。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM