【问题标题】:Prawn stroke_bounds in new pages新页面中的对虾stroke_bounds
【发布时间】:2018-10-08 19:47:31
【问题描述】:

我在我的 rails 项目中有使用 prawn 生成 pdf 的代码。

bounding_box([(bounds.left + 5), bounds.top - 130], width: 750) do    
        font_size(10)
        text "#{@post.description}", inline_format: :true, :overflow => :expand      
      end

文本的内容可能是 2-3 页。我想在文本周围创建一个边框。我该怎么做?

我试过transparent(0.5) { stroke_bounds } 但这只会给出单行。同样,我不能使用矩形,因为内容不固定。我该怎么做?

【问题讨论】:

    标签: ruby-on-rails prawn


    【解决方案1】:

    试试这个:

    bounding_box([(bounds.left + 5), bounds.top - 130], width: 750) do |t|   
      t.before_rendering_page do |page|
        stroke_bounds
      end
      font_size(10)
      text "#{@post.description}", inline_format: :true, :overflow => :expand      
    end
    

    它对我有用。我希望它对你也有用。 :)

    【讨论】:

    • 这仅适用于表格,不适用于边界框see manual
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多