Question

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>

Was it helpful?

Solution 2

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

OTHER TIPS

The pdf.text method will render what it is passed. To make the text bold you need to use

pdf.text, :font_style => :bold

A good way to get the docs is to run gem server

Then point your browser to http://localhost:8808/doc_root/prawn-core-0.8.4/rdoc/Prawn/Text.html

This will give you more details on the methods and some of the options.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top