Prawn::Document.generate('x.pdf") do text " x" text " x" end
Contrast to:
Prawn::Document.generate('x.pdf") do text "| x" text "| x" end
Not a bug. Intentional behavior change by Daniel. See:
http://groups.google.com/group/prawn-ruby/browse_thread/thread/836c1349ec76c720
Ok, but how i can render this indentation:
Prawn::Document.generate('x.pdf") do
text " xxxxxx
xxxxxx
xxxxxxxxxxxxx"
end
:indent_paragraphs property couldn`t help me with this.
Use non-breaking space: http://en.wikipedia.org/wiki/Non-breaking_space
Here's an example of how to do this using non-breaking spaces (here to display some code):
content = "def function(param)\n puts 'this'\nend"
content = content.gsub(/^(\s+)/m) { |m| "\xC2\xA0" * m.size }
font "courier" do
text content
end
@thbar your example breaks if you have multiple newlines. Use this instead:
content = content.gsub(/^([^\S\r\n]+)/m) { |m| "\xC2\xA0" * m.size }
content = content.gsub(/^([^\S\r\n]+)/m) { |m| "\xC2\xA0" * m.size }
after doing this I got
PDF's built-in fonts have very limited support for internationalized text.
If you need full UTF-8 support, consider using a TTF font instead.
To disable this warning, add the following line to your code:
Prawn::Font::AFM.hide_m17n_warning = true
Then downloaded a font and it works.
Thank you.
Most helpful comment
@thbar your example breaks if you have multiple newlines. Use this instead:
From http://stackoverflow.com/a/17752989/165673