Разделение слева направо в PDF-креветке - PullRequest
0 голосов
/ 10 июня 2019

В некоторых файлах PDF есть текст, где часть содержимого находится слева, а другие части - справа.Можно ли заставить Prawn делать это автоматически, когда текст автоматически переносится на правую половину страницы после заполнения левой половины?

Предоставляется пример изображения:

enter image description here

1 Ответ

1 голос
/ 10 июня 2019

Это свободно взято из руководства по креветкам (последнее обновление: 2019-06-09 - версия креветки: 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
...