22 pdf.text \"wold\", :size => 12" />
开发者

How to set two different font style in one single line with prawn in Ruby on Rails generating a PDF file?

I have the following code:


    pdf = Prawn::Document.new
    pdf.text "Hello", :size => 22
    pdf.text "wold", :size => 12

But th开发者_运维技巧is code displays two lines. I want to have the two text elements in one single line with the different font sizes as corresponding.


I'm not sure which tags are supported, but this might do the trick.

require 'prawn/format'
text "<font size=\"22\">Hello</font> <font size=\"12\">world</font>", inline_format => true

I found this answer here.


This is an old one, but now you can use the formatted_text method that way :

    formatted_text [ 
                     { text: "Hello", size: 22 },
                     { text: "world", size: 12 }
                   ]

more info in the manual : http://prawnpdf.org/manual.pdf

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜