gpt4 book ai didi

ruby-on-rails - 调试Prawn到达图形状态堆栈的末尾

转载 作者:行者123 更新时间:2023-12-03 16:06:42 25 4
gpt4 key购买 nike

class Report
attr_reader :pdf
def to_pdf
Prawn::Document.new(page_layout: page_layout) do |pdf|
@pdf = pdf

pdf.repeat(:all) do
frame_page
end

pdf.repeat(:all) do
write_header
end
#write_section_divider
puts "wrote the header" #this is not getting hit
write_body

在我的子类中:
def write_header
puts "Writing header"
pdf.move_down 8
pdf.text title, size: 22, style: :bold, align: :center
puts "wrote title"

pdf.bounding_box([0, pdf.cursor], width: pdf.bounds.right, height: 28) do
puts "bounding box"
pdf.move_down 8
pdf.text date_title, size: 16, align: :center
pdf.text current_day_title, size: 16, align: :center
puts "moved down"
end

puts "exited bounding box"
end


F, [2015-02-23T02:18:30.106303 #6] FATAL -- :
2015-02-23T02:18:30.106684+00:00 app[web.1]: app/reports/report.rb:6:in `to_pdf'
2015-02-23T02:18:30.106680+00:00 app[web.1]: app/reports/report.rb:13:in `block in to_pdf'
2015-02-23T02:18:30.106682+00:00 app[web.1]: app/reports/report.rb:6:in `new'
2015-02-23T02:18:30.106674+00:00 app[web.1]: Prawn::Errors::EmptyGraphicStateStack (
2015-02-23T02:18:30.106677+00:00 app[web.1]: You have reached the end of the graphic state stack):
2015-02-23T02:18:30.106690+00:00 app[web.1]:
2015-02-23T02:18:30.106691+00:00 app[web.1]:
2015-02-23T02:18:30.106688+00:00 app[web.1]: app/controllers/verified_return_money_reports_controller.rb:21:in `create'
2015-02-23T02:18:30.106687+00:00 app[web.1]: app/reports/verified_return_money_report.rb:6:in `to_pdf'

为什么我的虾画失败了?

最佳答案

您有一个转发器,该转发器应用于每个页面,并且其内容超过一个页面宽度。这就是Prawn告诉您的错误信息,它不是很容易解释。

现在,来自stacktrace的错误来自write_header调用。看来您在该方法上的边界框具有固定的高度(28),并且其内容更高:两行和move down 8

尝试扩展bounding_box的高度或使其内容更短。

关于ruby-on-rails - 调试Prawn到达图形状态堆栈的末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28666048/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com