【问题标题】:Left-right split in Prawn PDFPrawn PDF中的左右拆分
【发布时间】:2019-06-10 18:17:04
【问题描述】:

有些 PDF 的文本有些内容位于左侧,而其他部分位于右侧。是否可以让 Prawn 自动执行此操作,在左半部分填满后文本自动换行到页面的右半部分?

提供了一个示例图像:

【问题讨论】:

    标签: ruby pdf word-wrap prawn


    【解决方案1】:

    这是免费摘自 Prawn 手册(最后更新:2019-06-09 - Prawn 版本:2.2.2)第 43 页:

    require "prawn"
    
    Prawn::Document.generate("prince.pdf") do
    
      column_box([0, cursor], columns: 2, width: bounds.width) do
        text 'The Prince',          align: :center, size: 18
        text 'Niccolo Machiavelli', align: :center, size: 14
        move_down 12
        text "All the States and Governments by which men are or ever have been ruled,
          have been and are either Republics or Princedoms. Princedoms are either
          hereditary, in which the sovereignty is derived through an ancient line
          of ancestors, or they are new. New Princedoms are either wholly new, as
          that of Milan to Francesco Sforza; or they are like limbs joined on to
          the hereditary possessions of the Prince who acquires them, as the
          Kingdom of Naples to the dominions of the King of Spain. The States thus
          acquired have either been used to live under a Prince or have been free;
          and he who acquires them does so either by his own arms or by the arms of
          others, and either by good fortune or by merit." * 10
      end
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-29
      • 1970-01-01
      • 1970-01-01
      • 2019-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多