【问题标题】:Making a prawn table fit with a single header and repeating footer使虾桌适合单个页眉和重复页脚
【发布时间】:2015-11-18 19:48:35
【问题描述】:

我正在使用 Prawn 生成一个 PDF,该 PDF 在第一页上有一个页眉、一个重复的页脚和整个表格数据。

如果我添加没有边界框的表格,它会在页眉之后开始,但会与页脚重叠。 如果我将表格放在边界框内,它会避开页脚。但为了避免使用页眉,我必须将其放在页眉下方,然后在随后的每一页上都会丢失该空间。

还有其他方法吗?

【问题讨论】:

    标签: ruby pdf prawn


    【解决方案1】:

    在大虾的github上找到了答案。它要求您将表格包装在边界框中并手动设置边界框的起始位置,这只影响第一页。

      # ... draw your first-page header here
      # Store away the y-position below the header on the first page
      old_y = y
      # Start a bounding box the size of the page (excluding the footer)
      bounding_box([bounds.left, bounds.top],
          :width => bounds.width, :height => bounds.height - FooterHeight) do
        # Restore the old y-position for the first page
        self.y = old_y
        table(...)
      end
    

    https://github.com/prawnpdf/prawn/issues/309

    【讨论】:

      猜你喜欢
      • 2011-09-09
      • 1970-01-01
      • 1970-01-01
      • 2015-05-06
      • 1970-01-01
      • 2011-08-21
      • 1970-01-01
      • 2021-01-18
      • 1970-01-01
      相关资源
      最近更新 更多