简体   繁体   English

PRAWN导轨3中的方法大小未定义

[英]Undefined method size in PRAWN rails 3

Hi i'm getting error in this line of code: 嗨,我在这行代码中遇到错误:

pdf.font.size = 13

The name of the file is "show.pdf.prawn" 该文件的名称是“ show.pdf.prawn”

I'm trying to generate a page into pdf using the prawn gem. 我正在尝试使用大虾宝石将页面生成为pdf。

But changing the font size isn't working. 但是更改字体大小不起作用。

Any alternatives or workaround? 有其他选择或解决方法吗? Thanks. 谢谢。

BTW: I'm following a simple tutorial from railstips.org : http://railstips.org/blog/archives/2008/10/13/how-to-generate-pdfs-in-rails-with-prawn/ 顺便说一句:我正在跟踪railstips.org上的一个简单教程: http: //railstips.org/blog/archives/2008/10/13/how-to-generate-pdfs-in-rails-with-prawn/

Your tutorial seems to be a little bit old. 您的教程似乎有些陈旧。 You should have a look at this manual : http://prawn.majesticseacreature.com/manual.pdf and/or check the railscasts episode : http://railscasts.com/episodes/153-pdfs-with-prawn-revised . 您应该看一下本手册: http ://prawn.majesticseacreature.com/manual.pdf和/或查看railscasts集: http ://railscasts.com/episodes/153-pdfs-with-prawn-revised。

You can use the font_size property to define the size of your text like this : 您可以使用font_size属性来定义文本大小,如下所示:

font_size(25) { text "Even bigger!" }

You can also do it like this : 您也可以这样:

text "Single line on 20 using the :size option.", :size => 20

Or you can use a block to apply different font properties to your text : 或者,您可以使用块将不同的字体属性应用于文本:

    font("Courier", :size => 10) do
      text "Yeah, using Courier 10 courtesy of the font method."
    end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM