I spent a lot of hours tweaking numbers in my PDF source, trying to nudge things the right way, and, invariably, really messing up big-time...
Then one day I realized that all these numbers were supposed to be (INCHES * 72).
Now my PDF code looks more like:
pdf_begin_page($pdf, 8.5 * 72, 11 * 72);
. /* set up $helvetica as font */
pdf_set_font($pdf, $helvetica, 9);
$leading = pdf_get_value($pdf, 'leading');
pdf_show_boxed($pdf, 0.5 * 72, 0.5 * 72, 4.0 * 72, $leading, 'left', '');
0.0, 0.0 is at the bottom left.
8.5 * 72, 11 * 72 is at the top right.
Everything in between is in x.xx * 72 where x.xx is INCHES.
Suddenly, I can visualize the PDF while I'm typing.
Might work for you too.
Sample linked from: