eps 图像(来自 inkscape)未显示在 tcpdf 中

发布于 2024-08-26 21:58:48 字数 329 浏览 10 评论 0原文

使用php和TCPDF生成pdf文件。一切都很好,除了当我尝试使用 ImageEPS() 将 EPS 图像写入 pdf 时。什么也没有出现。没有错误(肯定能找到该文件)。它只是显示为空白。

光栅图像(如 PNG/JPG)工作得很好。

我正在使用 Inkscape 保存 .eps 文件。当我在任何其他程序中打开该文件时,它打开得很好。这是唯一没有出现的 TCPDF。

Using php and TCPDF to generate a pdf file. Everything works great except when I try to write an EPS image to the pdf using ImageEPS(). Nothing shows up. No errors (it can definitely find the file). It just shows up as white space.

Raster images (like PNG/JPG) work just fine.

I'm using Inkscape to save the .eps file. When I open the file up in any other program, it opens just fine. Its only TCPDF that its not showing up with.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

若无相欠,怎会相见 2024-09-02 21:58:48

我在 Adob​​e Illustrator 中打开我的 *.ai 文件并将该文件另存为“Illustrator 3”版本以解决该问题。任何更新的版本都会产生您所描述的结果(“Illustrator 8”除外,它为我提供了 *.ai 文件的黑白版本)。

I had open my *.ai file in Adobe Illustrator and save the file as "Illustrator 3" version to overcome that issue. Any more current version produced the results you describe (except "Illustrator 8," which gave me the B&W version of my *.ai file).

一抹苦笑 2024-09-02 21:58:48

有点晚了,但我也遇到了同样的问题。

对我来说,解决方法是导出为 PDF 并在 TCPDF/FPDI 中重用此 PDF:

$num_pages = $pdf->setSourceFile(path_to_file);  
$template_id = $pdf->importPage(1); //if the grafic is on page 1
$pdf->useTemplate($template_id,$x,$y,$width,$height);

A bit late, but I had the same problem.

For me, the workaround was to export as PDF and reuse this PDF in TCPDF/FPDI with:

$num_pages = $pdf->setSourceFile(path_to_file);  
$template_id = $pdf->importPage(1); //if the grafic is on page 1
$pdf->useTemplate($template_id,$x,$y,$width,$height);
蘸点软妹酱 2024-09-02 21:58:48

TCPDF (6.0.004) 中的 ImageEPS 函数尚未完全实现,文档说明如下:

/**
 * Embed vector-based Adobe Illustrator (AI) or AI-compatible EPS files.
 * NOTE: EPS is not yet fully implemented, use the 
 * setRasterizeVectorImages() method to enable/disable rasterization of 
 * vector images using ImageMagick library.
 * ...
 */
public function ImageEps(...){/*...*/}

TCPDF (6.0.004) 检查其创建者的 eps 元数据。如果创建者是 Adob​​e Illustrator,则会进行版本检查,如果版本高于 8,则会生成错误。
Adobe Illustrator 以外的创建者不会受到检查,并且允许该功能继续。 TCPDF 似乎没有解析 PS 序言,这可能是并非所有 AI 版本都受支持的原因之一。以下是 PostScript 语言参考 关于序言部分的内容

  • : prolog 是一组特定于应用程序的过程定义,应用程序
    化可以在执行其脚本时使用。它作为每个内容的第一部分包含在内
    由应用程序生成的 PostScript 文件。它包含匹配的定义
    应用程序的输出功能以及所支持的功能
    PostScript 语言。

由于prolog没有被解析,所以正确解释文件很麻烦。

Inkscape (0.48.3.1 r9886) 使用 cairo 创建 epses,不会发生错误,并且该功能将继续。 TCPDF 将部分解释 eps,但由于它不输出任何内容,因此输出可能会被某些错误处理删除。但这只是一个猜测。

我在将 eps 导出为 svg 方面取得了更大的成功
inkscape -D --file=文件名.eps --export-plain-svg=文件名.svg
并使用 ImageSVG 代替。注意:这个功能也没有完全实现,所以我不能保证它能工作。我只测试了一个非常基本的 eps。

The ImageEPS function in TCPDF (6.0.004) is not fully implemented and the documentation states the following:

/**
 * Embed vector-based Adobe Illustrator (AI) or AI-compatible EPS files.
 * NOTE: EPS is not yet fully implemented, use the 
 * setRasterizeVectorImages() method to enable/disable rasterization of 
 * vector images using ImageMagick library.
 * ...
 */
public function ImageEps(...){/*...*/}

TCPDF (6.0.004) checks an eps meta-data for its creator. If the creator is Adobe Illustrator, a version check is made and if the version is above 8 an error is generated.
Creators other than Adobe Illustrator are not checked and the function is allowed to continue. It does not seems like TCPDF parses the PS prolog and this is probably one reason why not all AI versions are supported. Here is what PostScript Language Reference says about the prolog section:

  • The prolog is a set of application-specific procedure definitions that an applica-
    tion may use in the execution of its script. It is included as the first part of every
    PostScript file generated by the application. It contains definitions that match
    the output functions of the application with the capabilities supported by the
    PostScript language.

Since the prolog is not parsed, it is troublesome to interpret the file correctly.

Inkscape (0.48.3.1 r9886) creates epses with cairo and no error will occur and the function will continue. TCPDF will partly interpret the eps, but since it does not output anything, the output is probably removed by some error handling. But that is just a guess.

I had more success with exporting my eps to a svg with
inkscape -D --file=filename.eps --export-plain-svg=filename.svg
and using ImageSVG instead. Note: this function is not fully implemented either, so I can't guarantee that it will work. I have only tested a pretty basic eps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文