开发者

eps image (from inkscape) not showing up in tcpdf

开发者 https://www.devze.com 2022-12-24 23:48 出处:网络
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 j

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. Wh开发者_开发技巧en I open the file up in any other program, it opens just fine. Its only TCPDF that its not showing up with.


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).


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);


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消