2011-11-02 5 views
0

새우를 사용하여 생성되는 PDF에 대한 스타일을 지정하기 위해 태그를 사용하려고합니다. 그러나 오류가있는 것으로 보입니다. 어떤 도움을 주시면 더 좋구요새우를 사용하여 PDF를 생성하는 중 오류가 발생했습니다.

/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) 

-

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 

나는 다음과 같은 오류가 발생합니다.

건배 !!

답변

1

그것은해야하지 :

tags[:h1] = { :font_size => "16pt", :font_weight => :bold } 

?

새우 0.7로, 새우 포맷이 완전히 지원되지 않는, 그리고 의지 새우 0.7+의 버전하지 일 :

또한 점에 유의하시기 바랍니다. 포크 고치고, 물론입니다.

는 새우에서 방법을 사용하여 고려 :: 텍스트

http://rubydoc.info/gems/prawn/0.12.0/Prawn/Text

EDIT 예를 들어

:

한이 일을 여러 가지 방법이다
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 

.

+0

태그를 [: h1]으로 변경해도 여전히 동일한 오류가 발생합니다. – verdure

+0

@verdure 새우 0.2.3은 일종의 오래된 것입니다 (일명 2008). 이 버전이 필요한 이유는 무엇입니까? – Ernest

+0

새우 버전을 확인하고 0.12.0으로 업데이트했지만 오류가 계속 발생합니다. – verdure

관련 문제