shairontoledo / rghost

RGhost is a document creation and conversion API. It uses the Ghostscript framework for the format conversion, utilizes EPS templates and is optimized to work with larger documents. Support(PDF,PS,GIF,TIF,PNG,JPG,etc)
http://rghost.rubyforge.org
MIT License
187 stars 46 forks source link

text_align: :center in text area doesn't produce accurate word wrapping #65

Open nkarki opened 9 years ago

nkarki commented 9 years ago

The word wrapping in text area worked awesome when using text_align left or right. But with text_align center it goes up to twice the width going outside the text area

The code snippet that I am using

doc = RGhost::Document.new
doc.define_tags do
  tag :font1, name: 'Helvetica', size: 14, color: '#0000FF'
end

doc.frame x: 6, y: 1, width: 1, height: 2, content: { fill: '#AAFA49'}
doc.text_area '<font1>test test test test hello awesome test yohohoho!!!'\ 
                      'abracadabra suntali testing word wrap</font1>', x: 6, y:3,
                      width: 1, row_height: 0.25, text_align: :center

left align output is as follows left_align

center align output is as follows center_align

shairontoledo commented 9 years ago

Can remove <font1> tag out of the string and share the result?

nkarki commented 9 years ago

Same results without the <font> tag. Left align works but not center align

left align left align no font

center align center align no font

nkarki commented 9 years ago

Hey Man,

Any chance that you had time to spend on this?

Thanks!

nkarki commented 9 years ago

Thank you for your earlier response.

I was able to add <br/> tags to the text_val with the help of rmagick gem which then rendered word wrap just the way I wanted.