Created
May 31, 2018 20:23
-
-
Save suryart/4b2947c83e67c350434a338177324553 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'prawn' | |
Prawn::Document.generate("./my_pdf.pdf") do | |
# Print Name | |
fill_color "565656" | |
font_size(38) { text "HEADING", align: :center } | |
move_down 20 | |
stroke_color "c0c0c0" #dimgray color code | |
text "cursor: #{cursor}" | |
column_box([0, cursor],:columns => 2, :width => bounds.width) do | |
fill_color "565656" | |
font_size(20) { text "SUB HEADING", align: :left } | |
# move_down 2 | |
fill_color "000000" | |
stroke do | |
line_width 0.5 | |
horizontal_rule | |
move_down 6 | |
end | |
string = ((<<-END.gsub(/\s+/,' ')+"\n\n")* 17) | |
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. | |
END | |
y_position = cursor - 5 | |
excess_text = text_box string, | |
width: bounds.width, | |
height: bounds.height, | |
overflow: :truncate, | |
at: [0, y_position] | |
excess_text = text_box excess_text, width: bounds.width, at: [0, y_position - 500] | |
text excess_text | |
# excess_text = text_box excess_text, width: 300, at: [100, y_position- 100] | |
# text string | |
# excess_text = text_box string, | |
# overflow: :truncate, | |
# at: [0, bounds.height] | |
# while excess_text | |
# fill_color "565656" | |
# font_size(20) { text "SUB HEADING", align: :left } | |
# # move_down 2 | |
# fill_color "000000" | |
# excess_text = text_box excess_text, | |
# overflow: :truncate, | |
# at: [0, 800] | |
# end | |
# excess_text = text string, overflow: :truncate | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment