prawnto and text format
Prawn/prawnto is cool stuff to 开发者_JS百科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>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.
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
精彩评论