Search code examples
pluginsruby-on-rails-3prawnprawnto

prawnto and text format


Prawn/prawnto is cool stuff to generate pdf file. But I am not able to render formatted text exactly as they are. Prawn is rendering all the html tags <b>, <i>, <p> as string. Below is the code i have written

pdf.text "#{@product.name}", :size => 20, :style => :bold
pdf.text "<b>Ashis Rai<b>"

and want to see the result as

Nokia N97  
Ashis Rai

but I am getting final result as below

Nokia N97
<b>Ashis Rai<b>


Solution

  • There is a below option that allows our formatted text to be render in pdf file

    :inline_format => true
    

    You can look over How can I do inline formatting (bold and underline) for PDF generated by Prawnto in Rails? by @Angela