Writing EPS images into PDF using FPDF with PHP

1.9k Views Asked by At

Im using FPDF library to generate PDF files and my requirement is to write .eps/.ai files into PDF file, for that Im using EPS/AI extension for this FPDF(http://www.fpdf.de/downloads/addons/1092/)

but when implement it in my code it is showing Error as

FPDF error: No BoundingBox found in EPS file: my_eps_file.eps

my PHP code is

$pdf->ImageEps('my_eps_file.eps', 15, 70, 20);

I have some text writing functions also in same file, if I remove this eps file writing statement everything is working fine, so I can say there is nothing wrong with library inclusion, but something is going wrong in EPS flow, can some one please help me, thank you.

2

There are 2 best solutions below

0
On

Also replace the line:

$lines = split ("\r\n|[\r\n]", $data); 

with the function preg_split:

$lines = preg_split ("/\r\n|[\r\n]/", $data); 
0
On

This function uses "ereg", that is deprecated. You must replace ereg with preg_match.

Replace this line

ereg ("%%BoundingBox:([^\r\n]+)", $data, $regs); 

With this one

preg_match("/%%BoundingBox:([^\r\n]+)/", $data, $regs);