PDA

View Full Version : Fpdf


twistedice
February 11th, 2007, 04:12 PM
Hi All,
Has anyone used FPDF before??? I have been using it to generate a few simple pdf's but i now have to add a logo, i can insert images fine but if i try to use a dynamic image it falls over with an error of: 'FPDF error: Image file has no extension and no type was specified:'.

The code is:
$logoName="/images/logo/retailer_9.jpg";
$this->Image($logoName,10,8,33);

If i use:
$this->Image('/images/logo/retailer_9.jpg',10,8,33);
it works fine

Its running on PHP, Does anyone have any ideas?

Cheers.

twistedice
February 14th, 2007, 12:57 PM
Sorry, being an idiot, got it sorted, was using functions and forgot the global call to the variable! :rotflmao:

degsy
February 14th, 2007, 01:46 PM
Thanks for the update :)

joseaguilar
February 28th, 2007, 12:57 PM
Hi twistedice,

I have the same problem. Please, tell me how did you solve it.

Thanks.

twistedice
February 28th, 2007, 01:14 PM
The problem i had was specifying an image in the header, which is a function all you need to do is add a global call to the variable within the function i.e


<?
//Variable to store image path
$headImage="/images/logo.jpg";

class PDF extends FPDF
{
//Page header
function Header()
{
//Global Call to Get image variable,
//without this the variable will not be passed to the function
global $headImage;

//Logo
$this->Image($headImage,10,8,33);

//Title
$this->Cell(30,10,'Title',1,0,'C');

//Line break
$this->Ln(20);
}
}
//Continue with the rest of your code
?>


Hope this helps

joseaguilar
February 28th, 2007, 01:50 PM
Well, I solved too. Just declare global the variables:

function Header()
{
global $logo, $titulo;
//Logo
$this->Image($logo,5,5,50);

....

}

Regards.

joseaguilar
February 28th, 2007, 01:51 PM
Thanks for your ultrafast answer.

Regards, Jose.