Reputation: 11
I'm implementing a pdf generator in PHP I have problem with word spacing, the option doesn't work or i'm not using word spacing parameter properly. I need this option to render text justified. The character spacing parameter works properly. This is how I'm rendering text:
BT
/F1 12 Tf
0 829 Td
5 Tw
(Hello world) Tj
ET
Word spacing parameter is bold. What i'm doing wrong?
Upvotes: 0
Views: 761
Reputation: 11
thanks for your answers. yes i was using unicode font. i deal with it with TJ operator. now my text output looks like that:
[(Hello) -320 (world) -320] TJ
Btw i must improve my text justify algoritm because text right align is not on one level. And i write my own library because existing ones do not have a tools which i need and all code is in one class - i split objects and objects elements into differend classes like Zend_Pdf
Upvotes: 1
Reputation: 15868
As BrianS mentioned, Tw isn't applied to multi-byte fonts according to the PDF Spec. That explains one of the text layout bugs I had to deal with Many Moons Ago. Ya learn something new every day.
There's another possibility. Word spacing is only applied to ASCII 0x20 (dec 32). If you're using a non-breaking space, tab, or whatever, instead of The ASCII Space, it won't work. Looking at the above text, that's not it, but your actual PDF output could differ.
Upvotes: 1