[英]Error generating pdf using prawn
I am trying to use tags to give some styling for a pdf being generated using prawn. 我正在尝试使用标签为使用大虾生成的pdf提供一些样式。 But, there seems to be an error. 但是,似乎有一个错误。
require 'rubygems'
require 'prawn'
require 'prawn/layout'
require 'prawn/format'
Prawn::Document.generate "example.pdf" do
tags:h1=>{ :font_size => "16pt", :font_weight => :bold }
text"<h1>Student Details</h1>"
end
I get the following error - 我收到以下错误-
/usr/lib/ruby/gems/1.8/gems/prawn-format-0.2.3/lib/prawn/format/text_object.rb:91:in `%': can't convert nil into Float (TypeError)
Any help is greatly appreciated. 任何帮助是极大的赞赏。
Cheers!! 干杯!!
Shouldn't it be: 不应该是:
tags[:h1] = { :font_size => "16pt", :font_weight => :bold }
? ?
Also please note that: 另请注意:
As of Prawn 0.7, prawn-format is completely unsupported, and will not work with versions of Prawn 0.7+. 从Prawn 0.7开始,完全不支持大虾格式,并且不适用于Prawn 0.7+版本。 Feel free to fork and fix, of course. 当然,可以随意进行分叉和修复。
Consider using methods from Prawn::Text 考虑使用Prawn :: Text中的方法
http://rubydoc.info/gems/prawn/0.12.0/Prawn/Text http://rubydoc.info/gems/prawn/0.12.0/Prawn/Text
EDIT 编辑
For example: 例如:
require 'rubygems'
require 'prawn'
Prawn::Document.generate('font_calculations.pdf') do
font "Courier", :size => 16, :style => :bold
text "Student details"
font "Courier", :size => 12, :style => :normal
text "normal text"
text "this is normal, <b>but this is bold</b>", :inline_format => true
text "normal <font size='18'>bigger</font> normal", :inline_format => true
end
That's just one of many ways of doing this. 那只是许多方式中的一种。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.