【问题标题】:Using Prawn gem on rails app repeating footer with current page and total page count on each page , but getting overlapping current page number在 Rails 应用程序上使用 Prawn gem 重复页脚与当前页面和每页上的总页数,但获取重叠的当前页码
【发布时间】:2015-06-24 06:41:06
【问题描述】:

这是我的代码

repeat :all do
  # footer
  bounding_box [bounds.left, bounds.bottom + 35], :width  => bounds.width do
    font "Helvetica"
    move_down(15)
    number_pages "Page <page> of <total>",
                 { :start_count_at => 1, :page_filter => :all,:at => [bounds.right - 50, 0],
                   :align => :right,
                   :size => 8}
  end
end

当前错误结果与当前页码重叠,例如“第 12 页(1 和 2 自身重叠),共 2”...但最后一页结果类似于“第 2 页,共 2 页”,这是正确的

【问题讨论】:

    标签: ruby-on-rails header footer prawn overlapping


    【解决方案1】:

    解决办法是用canvas代替repeat :all

    这是有效的解决方案:

    canvas do
      bounding_box [bounds.left, bounds.bottom + 50], :width  => bounds.width do
        font "Helvetica"
        move_down(15)
        number_pages "Page <page> of <total>",
                     { :start_count_at => 1, :page_filter => :all,:at => [bounds.right - 70, 10],
                       :size => 8}
        move_down(8)
        number_pages "This is an automatically generated certificate from BlaBla (blabla.com)", :size => 8, :align => :center,:at => [0, 0]
        number_pages "Downloaded on #{Date.today.to_formatted_s(:long)} by #{@user.full_name}", :size => 8, :align => :center,:at => [0, 10]
      end
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-01
      • 1970-01-01
      • 2014-07-23
      • 2016-08-14
      • 2016-05-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多