5

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.

Josh
  • 10,961
  • 11
  • 65
  • 108
Joshua
  • 61
  • 2
  • 4

3 Answers3

3

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

David L Ernstrom
  • 449
  • 2
  • 11
  • I'm testing the TCPDF library as well and sadly, I'm finding that only Illustrator 3 files work. I can confirm that when I do Illustrator 8, it's almost all black (not B&W, brown text comes through, but no vector artwork colors) and Illustrator 9 and above don't work at all. – Josh Sep 30 '11 at 14:22
2

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);
toxalot
  • 11,260
  • 6
  • 35
  • 58
Ludwig
  • 21
  • 1
0

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.

D. Josefsson
  • 1,052
  • 7
  • 21