谢谢伊戈尔
我目前正在设置当前页面,然后在呈现新表之后和回滚设置 new_page 变量之前在事务中。然后我可以回滚并检查新页面变量>当前页面变量是否开始新页面并打印表格。请参阅下面的代码。
现在的问题是 pdf.start_new_page 说错误,但如果我只是取出 pdf.rollback 行,它就可以工作。请参阅下面的错误。
任何想法,任何一种或任何更简单的方法,都必须有一个!
谢谢瑞克
@current_page = pdf.page_count
pdf.transaction do
pdf.move_down 20
pdf.table @data,
:font_size => 12,
:border_style => :grid,
:horizontal_padding => 10,
:vertical_padding => 3,
:border_width => 2,
:position => :left,
:row_colors => ["FFFFFF","DDDDDD"]
@the_next_page = pdf.page_count
pdf.rollback
end
if @the_next_page > @current_page
pdf.start_new_page
pdf.table @data,
:font_size => 12,
:border_style => :grid,
:horizontal_padding => 10,
:vertical_padding => 3,
:border_width => 2,
:position => :left,
:row_colors => ["FFFFFF","DDDDDD"]
end
错误
> You have a nil object when you didn't expect it!
The error occurred while evaluating nil.identifier
Extracted source (around line #158):
155: end
RAILS_ROOT: C:/InstantRails/rails_apps/Macrotec-Application
Application Trace | Framework Trace | Full Trace
c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/prawn-core-0.7.1/lib/prawn/document.rb:302:in `go_to_page'
c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/prawn-core-0.7.1/lib/prawn/document/internals.rb:128:in `finalize_all_page_contents'
c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/prawn-core-0.7.1/lib/prawn/document/internals.rb:127:in `each'
c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/prawn-core-0.7.1/lib/prawn/document/internals.rb:127:in `finalize_all_page_contents'
c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/prawn-core-0.7.1/lib/prawn/document.rb:344:in `render'
C:/InstantRails/rails_apps/Macrotec-Application/app/views/quotations/show.pdf.prawn:158:in `_run_prawn_app47views47quotations47show46pdf46prawn'