1

I am having a problem with fpdf and its eps extension that I can't seem to get past it. This is what my code looks like:

define('FPDF_FONTPATH','fpdf/font/');
require('fpdf/fpdf_eps.php');
$pdf = new PDF_EPS();
$pdf->AddPage();
$pdf->ImageEps("images/image.eps",50,100);
$pdf->AddPage();
$pdf->SetFont('Arial','B',14);
$pdf->MultiCell(0,5,"some text with multiple lines");
$pdf->Output("filname.pdf", "D");

And this is what I constantly get:

Strict Standards: Only variables should be passed by reference in (...php file and line...)

FPDF error: Could not include font metric file

Any help will be greatly appreciated.

The eps extension can be found here: http://valentin.dasdeck.com/fpdf/fpdf_eps

Community
  • 1
  • 1
gtrianta
  • 21
  • 7

1 Answers1

0

About Strict Standards: Only variables should be passed by reference in (...php file and line...)

This means what it says.. You can only hand variables by reference (the & characters before arguments in the function definition). You can either lose the & or make sure error_reporting() does not include E_STRICT, which will suppress this warning. (at any rate php should just copy whatever you pass to that function instead of handing over a reference to it so i wouldn't worry about it)

Regarding: FPDF error: Could not include font metric file

This error is related to SetFont(). There should be a .ufm or .afm file for Arial (or whatever font you want to load) in the font path so fpdf can load and use them.

Gung Foo
  • 13,392
  • 5
  • 31
  • 39
  • I understand what you say about the SetFont function. FPDF has several font metric information in php format for different fonts (for Arial it has an Helvetica equivalent). However, the thing is that when I use the fpdf class without the eps extension (with a simple jpg image) everything works fine. The font files reside both times in the same path, but when I use the eps extension, it's as if php cannot see them... – gtrianta Oct 18 '12 at 12:51
  • This is what I get with an absolute path:FPDF error: Some data has already been output, can't send PDF file – gtrianta Oct 18 '12 at 13:04
  • it seems you are sending some output to the client before $pdf->Output() tries to send http-headers.. (echo, var_dump, print_r).. remove the output or use output buffering. you can comment out the call to Output() to see what is being output – Gung Foo Oct 18 '12 at 13:06
  • Nothing is displayed... I have no echo, var_dump or print_r before $pdf->Output() – gtrianta Oct 18 '12 at 13:15
  • well.. that error does not relate to the font problem anymore.. it is caused by ANY output (even if it is a whitespace) to the client before the call to Output(). http://stackoverflow.com/questions/9475686/fpdf-error-some-data-has-already-been-output-cant-send-pdf – Gung Foo Oct 18 '12 at 13:18
  • Thank you! The last comment (@Cino Jose) on the thread you referred to did the trick :-) – gtrianta Oct 18 '12 at 13:36
  • Last question about the font metric thing: It works with the absolute path but still crashes with a relative path. What form will the absolute path have to have when I upload the php file on the actual server (I am working locally now)? – gtrianta Oct 18 '12 at 13:43
  • i figure that the FONTPATH will have to be relative to 'fpdf/fpdf_eps.php'... If it is absolute, it should work in any case. – Gung Foo Oct 18 '12 at 13:46