pdf generation - How to set horizontal or vertical alignment Text in PDF? -


i generating pdf, , outputting text, e.g.:

bt   /f1 7 tf   586 406 td   (date shipped:) tj et 

a quick primer on pdf programming language:

  • bt: begin text block
  • /f1 7 tf: select font #1 (which in case helvetica), , use font size of 7 point
  • 586 406 td move current location (x=586 pt, y=406 pt)
  • (date shipped:) tj: render text date shipped:
  • et: end text block

that text rendered @ location (586,406), bottom left of text block @ location:

enter image description here

what want point define top center point:

enter image description here

because not know size of rendered text; cannot fudge things up/down/left/right try make it.

how can indicate in pdf text's "alignment"?

you cannot. pdf producing software needs know font metrics produce formatted output.

as know selected helvetica @ size 7 , know current character , word spacing values, can calculate size of rendered text.

the font metrics of standard 14 fonts available here.

you may want read pdf specification (made available here), chapter on text rendering.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -