Here's a little function that creates a pdf_show_xy_right() function with exactly the same parameters as pdf_show_xy(), except that the third parameter now specifies the right-aligned edge position.
function pdf_show_xy_right(&$pdf, $text, $right, $bottom) {
$fontname = pdf_get_parameter($pdf, "fontname", 0);
$font = pdf_findfont($pdf, $fontname, "host", 0);
$size = pdf_get_value($pdf, "fontsize", 0);
$width = pdf_stringwidth($pdf, $text, $font, $size);
pdf_show_xy($pdf, $text, $right-$width, $bottom);
}
Set your font name and size separately, just as you would with pdf_show_xy(), and then call this function like so:
pdf_show_xy_right($pdf, "Hello World", 50, 200);
The third parameter is the right edge, fourth parameter is the baseline. You do NOT have to pass in the font and size!