By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,740 Members | 844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,740 IT Pros & Developers. It's quick & easy.

FPDF

P: n/a
been gleening the user docs for fpdf. there's one simple example for using
the image function. i can't seem to get it to work. has anyone else had
problems with this, and if so, what did you do to diagnose and fix the
problem?

tia,

me
Oct 9 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Steve" <no****@example.comwrote in news:cp*************@newsfe03.lga:
been gleening the user docs for fpdf. there's one simple example for
using the image function. i can't seem to get it to work. has anyone
else had problems with this, and if so, what did you do to diagnose
and fix the problem?

tia,

me

i've used FPDF and image() successfully... what problems are you having?
Oct 9 '07 #2

P: n/a
"Good Man" <he***@letsgo.comwrote in message
news:Xn************************@216.196.97.131...
"Steve" <no****@example.comwrote in news:cp*************@newsfe03.lga:
>been gleening the user docs for fpdf. there's one simple example for
using the image function. i can't seem to get it to work. has anyone
else had problems with this, and if so, what did you do to diagnose
and fix the problem?

tia,

me


i've used FPDF and image() successfully... what problems are you having?
i just get a blank space where an image should be. there are no errors that
indicate my path is wrong...or anything else. i just get a blank space.
here's my test code:

<?
header('content-type: application/pdf');
require_once 'table.pdf.class.php'; // test class to ease table creating
// only calls cell() in fpdf but in a
way
// that make it more html-like in
creation
$imagePath = 'c:/inetpub/wwwroot/toyotaii/images/';
$pdf = new pdfTable();
$pdf->addPage();
$pdf->setFont('Arial', '', 8);
$image = $pdf->image($imagePath . 'tccc.logo.jpg', $pdf->getX(),
$pdf->getY());
$pdf->ln();
$header = array('Country', 'Capital', 'Area (sq km)', 'Pop.
(thousands)');
$data = $pdf->loadData('countries.txt');
$pdf->table($header, $data);
$pdf->output();
?>

i did refactor the fpdf class so that all is camel-cased which is our bp for
this customer. however, i tested everything before, during, and after
refactoring to make sure nothing got messed up. at no time did i get an
image.

it's probably just me, but i really didn't find much about using the image
function other than a one line example.

whatever light you can shed will help greatly.

thanks,

me
Oct 9 '07 #3

P: n/a
"Steve" <no****@example.comwrote in news:wT************@newsfe03.lga:
$image = $pdf->image($imagePath . 'tccc.logo.jpg', $pdf->getX(),
$pdf->getY());
two quick troubleshooting things: try assigning variables for $pdf->getX()
and $pdf->getY() and use the variables, and/or try replacing those entirely
with some numerical coordinates just to make sure its being printed
somewhere.

also, i notice that my scripts specify a fourth parameter (the optional
'image width' specification) numerically... if you leave it out, it is
"automatically calculated" for better or worse. See if it makes a
difference?

I don't know if you can use actual numbers for your class calls, but most
of the PDFs I've generated with FPDF have a specific place for my images,
thus I am able to use numbers all around ie:

$pdf->Image('images/receipt300.png',10,8,200);
.... to sum up, try replacing variables with numbers, and if it prints, then
the variables are wrong...
FPDF sure does require a lot of trial-and-error time!!!!
Oct 9 '07 #4

P: n/a
"Steve" <no****@example.comwrote in news:wT************@newsfe03.lga:
i just get a blank space where an image should be. there are no errors
that indicate my path is wrong...or anything else. i just get a blank
space. here's my test code:

<?
header('content-type: application/pdf');
require_once 'table.pdf.class.php'; // test class to ease table
creating
// only calls cell() in fpdf but
in a
way
// that make it more html-like in
creation
$imagePath = 'c:/inetpub/wwwroot/toyotaii/images/';
$pdf = new pdfTable();
$pdf->addPage();
$pdf->setFont('Arial', '', 8);
$image = $pdf->image($imagePath . 'tccc.logo.jpg', $pdf->getX(),
$pdf->getY());
And I just noticed this, the function is Image() not image() but perhaps
thats irrelevant if you've camelCased the function definition.
Oct 9 '07 #5

P: n/a

"Good Man" <he***@letsgo.comwrote in message
news:Xn************************@216.196.97.131...
"Steve" <no****@example.comwrote in news:wT************@newsfe03.lga:
>$image = $pdf->image($imagePath . 'tccc.logo.jpg', $pdf->getX(),
$pdf->getY());

two quick troubleshooting things: try assigning variables for $pdf->getX()
and $pdf->getY() and use the variables, and/or try replacing those
entirely
with some numerical coordinates just to make sure its being printed
somewhere.
the getX and getY calls were from a suggested post i'd come across with
someone else having problems with image(). i put in hard coded values but to
no avail.

also, i notice that my scripts specify a fourth parameter (the optional
'image width' specification) numerically... if you leave it out, it is
"automatically calculated" for better or worse. See if it makes a
difference?
yeah, there's a width and height param that are optional. i've hard coded
both, either, and none. still blank space.
I don't know if you can use actual numbers for your class calls, but most
of the PDFs I've generated with FPDF have a specific place for my images,
thus I am able to use numbers all around ie:

$pdf->Image('images/receipt300.png',10,8,200);
yeah, i've tried that too...very frustrating.
... to sum up, try replacing variables with numbers, and if it prints,
then
the variables are wrong...
FPDF sure does require a lot of trial-and-error time!!!!
surprisingly less than what i expected...especially since looking at the
source, just getting it up to *some* kind of *good* coding style is a
hurculean task. ;^) anyway, everything i have works with the exception of
image(). it's my first time to generate pdf's in this way and i'm
prototyping reporting functions with pdf output.

before, we'd cheat. we had a pdf print driver on the server and just capture
the normal html and pipe it to the driver to file, and then show/email/etc.
the file. not an option this time.

anyway, thanks for your help.
Oct 9 '07 #6

P: n/a

"Good Man" <he***@letsgo.comwrote in message
news:Xn************************@216.196.97.131...
"Steve" <no****@example.comwrote in news:wT************@newsfe03.lga:
>i just get a blank space where an image should be. there are no errors
that indicate my path is wrong...or anything else. i just get a blank
space. here's my test code:

<?
header('content-type: application/pdf');
require_once 'table.pdf.class.php'; // test class to ease table
creating
// only calls cell() in fpdf but
in a
way
// that make it more html-like in
creation
$imagePath = 'c:/inetpub/wwwroot/toyotaii/images/';
$pdf = new pdfTable();
$pdf->addPage();
$pdf->setFont('Arial', '', 8);
$image = $pdf->image($imagePath . 'tccc.logo.jpg', $pdf->getX(),
$pdf->getY());

And I just noticed this, the function is Image() not image() but perhaps
thats irrelevant if you've camelCased the function definition.
right. that's exactly it. fpfd has been brought into conformance with our
clients best practices...which, part of that is camelCasing interface names
rather than PascalNotation.
Oct 9 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.