2

In pdflib:

$font = $p->load_font("Helvetica", "unicode", "");
$p->setfont($font, 12);
$p->set_text_pos(100, 100);
$p->show('My text');

First arguments of set_text_pos($x, $y) tells library where to position bottom-left corner of text element.

Question. How can I change the origin of text to be top-left corner, so that "My text" string appears below 100x100 coordinate?

temuri
  • 2,767
  • 5
  • 41
  • 63

1 Answers1

1

I would recommend to use the more comfortable fit_textline() call. In this case, you can replace your four lines with a single line:

$p->fit_textline('My text', 100, 100, 'fontname=Helvetica encoding=unicode fontsize=12 position {top left} ');
Rainer
  • 2,013
  • 1
  • 10
  • 7