Camarão::Document.generate('x.pdf") do texto "x" texto "x" fim
Contrasta com:
Camarão::Document.generate('x.pdf") do texto "| x" texto "| x" fim
Não é um erro. Mudança de comportamento intencional por Daniel. Ver:
http://groups.google.com/group/prawn-ruby/browse_thread/thread/836c1349ec76c720
Ok, mas como eu posso renderizar esse recuo:
Prawn::Document.generate('x.pdf") do
text " xxxxxx
xxxxxx
xxxxxxxxxxxxx"
end
:indent_paragraphs propriedade não poderia me ajudar com isso.
Use espaço ininterrupto: http://en.wikipedia.org/wiki/Non-breaking_space
Aqui está um exemplo de como fazer isso usando espaços sem quebra (aqui para exibir algum código):
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 seu exemplo quebra se você tiver várias novas linhas. Use isso em vez disso:
content = content.gsub(/^([^\S\r\n]+)/m) { |m| "\xC2\xA0" * m.size }
content = content.gsub(/^([^\S\r\n]+)/m) { |m| "\xC2\xA0" * m.size }
depois de fazer isso eu consegui
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
Em seguida, baixei uma fonte e funciona.
Obrigada.
Comentários muito úteis
@thbar seu exemplo quebra se você tiver várias novas linhas. Use isso em vez disso:
De http://stackoverflow.com/a/17752989/165673