Link to home
Start Free TrialLog in
Avatar of worldofwires
worldofwiresFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Using Images in FPDF

Hi,
I've been using a few FPDF routines in my project for years without a hitch. I've also used the Image function to successfully place a couple of PNG flags in the document. Now I'm trying to place a few extra smaller flags in a few places in the document. I'm using almost the exact same code which renders them fine and yet I can't get it working. Can someone take a look at the code snippets below and see if they can see anything wrong please?

Firstly, this is how I call the flags with success earlier in the document:
if($grph==1) {
	$y=$this->GetY();
	$this->Image("images/flags/".$data['home_cc'].".png", 15, $y, 7, 3.5);
	$this->Image("images/flags/".$data['host_cc'].".png", 15, $y+5, 7, 3.5);
}

Open in new window


No problems there. Then I try to call almost the same code within a function which prints a line at a time which I call from a FOREACH loop. The loop looks like this:
foreach($data['pre_tax_remuneration'] as $row) {
	if($row[3]==1) $fl=$data['home_cc']; else $fl=$data['host_cc'];
	$this->Breakdown_Values($row[0], $row[$curr+1], $x1, $fl);
}

Open in new window

$row[3] is just a two letter string of the country and I'#ve checked that that is making it through to the function correctly. So, the function is:
function Breakdown_Values($title, $value, $x, $fl) {
global $c;
$this->SetX($x);
$this->SetFont('Arial','',10);
$this->SetTextColor($c['txt_2']['r'], $c['txt_2']['g'], $c['txt_2']['b']);
$this->Cell(50,4.5,$title,0,0,'L',1);
	$this->SetTextColor($c['txt_1']['r'], $c['txt_1']['g'], $c['txt_1']['b']);
	$this->Cell(35,4.5,display_number($value),0,0,'R',1);
	if($fl!=0) {
		$y=$this->GetY();
		$this->Image("images/flags/".$fl.".png", $x+1, $y, 3, 2);
	}
	$this->Ln();		
}

Open in new window


$c is just an array of a colour. I've tried playing about with the $x and $y values just to get it placed somewhere in the document but it never seems to appear.

Can anyone spot why? This is really bugging me ebcause I've now spent over two hours trying everything I can think of but with no success.

The manual for the FPDF is here and I use version 1.6.

I greatly appreciate any help/input.

John
ASKER CERTIFIED SOLUTION
Avatar of worldofwires
worldofwires
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial