2013-11-24 44 views
5

根据boolean的结果,是否可以让Prawn填充复选框?例如,我想为一系列问题设置“是”和“否”复选框来记录回复。在收到这些信息后,我希望填写适当的复选框。这是可能的,如果是这样,怎么办?与虾宝石复选框

谢谢!

回答

3

有一个要点here讨论这一点。 尽管基本的想法是,你需要使用支持复选框的字体集才能使其工作。

如果你想要比这更奇特的东西,虾不支持开箱即用的复选框,所以你需要为此创建一些东西。

+1

PDF查看器仅被[保证有14种字体](http://www.enfocus.com/manuals/ReferenceGuide/PP/10/enUS/en-us/concept/c_aa1140975.html)和Unicode支持pdf [仅限于最好](http://stackoverflow.com/a/143702/616644)。最便携的解决方案可能会自己绘制它们。 –

2

自己画这个并不难。这对我来说是一个非常灵活的解决方案。

def checkbox(flag, x_position = 7, y_position = @pdf.cursor - 2) 
    @pdf.bounding_box([x_position, y_position], width: 10, height: 12) do 
    @pdf.stroke_bounds 
    @pdf.text("X", align: :center, valign: :center) if flag 
    end 
end