Langostino::Documento.generar('x.pdf") hacer texto "x" texto "x" final
Contraste con:
Langostino::Documento.generar('x.pdf") hacer texto "|x" texto "|x" final
No es un error. Cambio de comportamiento intencional por Daniel. Ver:
http://groups.google.com/group/prawn-ruby/browse_thread/thread/836c1349ec76c720
Ok, pero ¿cómo puedo representar esta sangría?
Prawn::Document.generate('x.pdf") do
text " xxxxxx
xxxxxx
xxxxxxxxxxxxx"
end
La propiedad :indent_paragraphs no pudo ayudarme con esto.
Utilice espacios de no separación: http://en.wikipedia.org/wiki/Non-breaking_space
Aquí hay un ejemplo de cómo hacer esto usando espacios que no se rompen (aquí para mostrar algo de 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, su ejemplo se rompe si tiene varias líneas nuevas. Usa esto en su lugar:
content = content.gsub(/^([^\S\r\n]+)/m) { |m| "\xC2\xA0" * m.size }
contenido = contenido.gsub(/^([^\S\r\n]+)/m) { |m| "\xC2\xA0" * m.tamaño }
después de hacer esto obtuve
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
Luego descargué una fuente y funciona.
Gracias.
Comentario más útil
@thbar, su ejemplo se rompe si tiene varias líneas nuevas. Usa esto en su lugar:
De http://stackoverflow.com/a/17752989/165673