fullcirclegroup-fullcirclegroup-prawn 0.2.99.2
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +340 -0
- data/LICENSE +56 -0
- data/README +47 -0
- data/Rakefile +76 -0
- data/data/fonts/Activa.ttf +0 -0
- data/data/fonts/Chalkboard.ttf +0 -0
- data/data/fonts/Courier-Bold.afm +342 -0
- data/data/fonts/Courier-BoldOblique.afm +342 -0
- data/data/fonts/Courier-Oblique.afm +342 -0
- data/data/fonts/Courier.afm +342 -0
- data/data/fonts/DejaVuSans.ttf +0 -0
- data/data/fonts/Dustismo_Roman.ttf +0 -0
- data/data/fonts/Helvetica-Bold.afm +2827 -0
- data/data/fonts/Helvetica-BoldOblique.afm +2827 -0
- data/data/fonts/Helvetica-Oblique.afm +3051 -0
- data/data/fonts/Helvetica.afm +3051 -0
- data/data/fonts/MustRead.html +19 -0
- data/data/fonts/Symbol.afm +213 -0
- data/data/fonts/Times-Bold.afm +2588 -0
- data/data/fonts/Times-BoldItalic.afm +2384 -0
- data/data/fonts/Times-Italic.afm +2667 -0
- data/data/fonts/Times-Roman.afm +2419 -0
- data/data/fonts/ZapfDingbats.afm +225 -0
- data/data/fonts/comicsans.ttf +0 -0
- data/data/fonts/gkai00mp.ttf +0 -0
- data/data/images/arrow.png +0 -0
- data/data/images/arrow2.png +0 -0
- data/data/images/barcode_issue.png +0 -0
- data/data/images/dice.alpha +0 -0
- data/data/images/dice.dat +0 -0
- data/data/images/dice.png +0 -0
- data/data/images/page_white_text.alpha +0 -0
- data/data/images/page_white_text.dat +0 -0
- data/data/images/page_white_text.png +0 -0
- data/data/images/pigs.jpg +0 -0
- data/data/images/rails.dat +0 -0
- data/data/images/rails.png +0 -0
- data/data/images/ruport.png +0 -0
- data/data/images/ruport_data.dat +0 -0
- data/data/images/ruport_transparent.png +0 -0
- data/data/images/ruport_type0.png +0 -0
- data/data/images/stef.jpg +0 -0
- data/data/images/web-links.dat +1 -0
- data/data/images/web-links.png +0 -0
- data/data/shift_jis_text.txt +1 -0
- data/examples/addressbook.csv +6 -0
- data/examples/alignment.rb +16 -0
- data/examples/bounding_boxes.rb +30 -0
- data/examples/canvas.rb +12 -0
- data/examples/cell.rb +38 -0
- data/examples/chinese_text_wrapping.rb +17 -0
- data/examples/currency.csv +1834 -0
- data/examples/curves.rb +10 -0
- data/examples/family_based_styling.rb +21 -0
- data/examples/fancy_table.rb +61 -0
- data/examples/flowing_text_with_header_and_footer.rb +72 -0
- data/examples/font_size.rb +27 -0
- data/examples/hexagon.rb +14 -0
- data/examples/image.rb +23 -0
- data/examples/image2.rb +13 -0
- data/examples/image_flow.rb +34 -0
- data/examples/kerning.rb +27 -0
- data/examples/lazy_bounding_boxes.rb +19 -0
- data/examples/line.rb +31 -0
- data/examples/multi_page_layout.rb +14 -0
- data/examples/page_geometry.rb +28 -0
- data/examples/png_types.rb +23 -0
- data/examples/polygons.rb +16 -0
- data/examples/position_by_baseline.rb +26 -0
- data/examples/ruport_formatter.rb +50 -0
- data/examples/ruport_helpers.rb +18 -0
- data/examples/russian_boxes.rb +34 -0
- data/examples/simple_text.rb +15 -0
- data/examples/simple_text_ttf.rb +16 -0
- data/examples/sjis.rb +21 -0
- data/examples/span.rb +27 -0
- data/examples/table.rb +47 -0
- data/examples/table_header_color.rb +16 -0
- data/examples/text_flow.rb +65 -0
- data/examples/top_and_bottom_cells.rb +40 -0
- data/examples/utf8.rb +12 -0
- data/lib/prawn.rb +67 -0
- data/lib/prawn/compatibility.rb +46 -0
- data/lib/prawn/document.rb +309 -0
- data/lib/prawn/document/bounding_box.rb +362 -0
- data/lib/prawn/document/internals.rb +113 -0
- data/lib/prawn/document/page_geometry.rb +79 -0
- data/lib/prawn/document/span.rb +47 -0
- data/lib/prawn/document/table.rb +350 -0
- data/lib/prawn/document/text.rb +196 -0
- data/lib/prawn/errors.rb +48 -0
- data/lib/prawn/font.rb +356 -0
- data/lib/prawn/font/cmap.rb +59 -0
- data/lib/prawn/font/metrics.rb +378 -0
- data/lib/prawn/font/wrapping.rb +47 -0
- data/lib/prawn/graphics.rb +252 -0
- data/lib/prawn/graphics/cell.rb +264 -0
- data/lib/prawn/graphics/color.rb +132 -0
- data/lib/prawn/images.rb +336 -0
- data/lib/prawn/images/jpg.rb +45 -0
- data/lib/prawn/images/png.rb +199 -0
- data/lib/prawn/pdf_object.rb +73 -0
- data/lib/prawn/reference.rb +56 -0
- data/spec/bounding_box_spec.rb +141 -0
- data/spec/document_spec.rb +181 -0
- data/spec/font_spec.rb +141 -0
- data/spec/graphics_spec.rb +209 -0
- data/spec/images_spec.rb +68 -0
- data/spec/jpg_spec.rb +25 -0
- data/spec/metrics_spec.rb +62 -0
- data/spec/pdf_object_spec.rb +112 -0
- data/spec/png_spec.rb +196 -0
- data/spec/reference_spec.rb +42 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/table_spec.rb +179 -0
- data/spec/text_spec.rb +135 -0
- metadata +181 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require "prawn"
|
5
|
+
|
6
|
+
Prawn::Document.generate("baseline.pdf") do
|
7
|
+
pos = self.y - margin_box.absolute_bottom
|
8
|
+
stroke do
|
9
|
+
horizontal_rule
|
10
|
+
line [0,pos], [0,pos - font.height*2]
|
11
|
+
end
|
12
|
+
|
13
|
+
bounding_box(bounds.top_left, :width => 250) do
|
14
|
+
text "blah blah blah"
|
15
|
+
text "fasjkafsk asfkjfj saklfs asfklafs"
|
16
|
+
end
|
17
|
+
|
18
|
+
bounding_box([300,bounds.top], :width => 250) do
|
19
|
+
# This is how you can position the text exactly at the baseline
|
20
|
+
move_up font.height
|
21
|
+
text "blah blah blah"
|
22
|
+
text "fasjkafsk asfkjfj saklfs asfklafs"
|
23
|
+
end
|
24
|
+
|
25
|
+
stroke_horizontal_rule
|
26
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require "prawn"
|
5
|
+
|
6
|
+
ruby_18 do
|
7
|
+
require "rubygems"
|
8
|
+
require "ruport"
|
9
|
+
|
10
|
+
module Ruport
|
11
|
+
class Formatter
|
12
|
+
class PrawnPDF < Ruport::Formatter
|
13
|
+
renders :pdf, :for => Ruport::Controller::Table
|
14
|
+
|
15
|
+
def document
|
16
|
+
@document ||= (options.document || Prawn::Document.new)
|
17
|
+
end
|
18
|
+
|
19
|
+
def table_body
|
20
|
+
data.map { |e| e.to_a }
|
21
|
+
end
|
22
|
+
|
23
|
+
build :table_header do
|
24
|
+
@headers = options.headers || data.column_names
|
25
|
+
end
|
26
|
+
|
27
|
+
build :table_body do
|
28
|
+
document.table table_body,
|
29
|
+
:headers => @headers,
|
30
|
+
:row_colors => :pdf_writer,
|
31
|
+
:position => :center,
|
32
|
+
:font_size => 10,
|
33
|
+
:vertical_padding => 2,
|
34
|
+
:horizontal_padding => 5
|
35
|
+
end
|
36
|
+
|
37
|
+
def finalize
|
38
|
+
output << document.render
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
if __FILE__ == $PROGRAM_NAME
|
46
|
+
t = Table("#{Prawn::BASEDIR}/examples/addressbook.csv")
|
47
|
+
headers = t.column_names.map { |c| c.capitalize }
|
48
|
+
t.save_as "addressbook_ruport.pdf", :headers => headers
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require "prawn"
|
5
|
+
|
6
|
+
# Demonstrates some features stolen from Ruport::Formatter::PDF
|
7
|
+
Prawn::Document.generate("ruport.pdf") do
|
8
|
+
move_down 50
|
9
|
+
# TODO: Figure out where to set the y cursor to.
|
10
|
+
stroke_horizontal_rule
|
11
|
+
text "Hi there"
|
12
|
+
pad(50) { text "I'm Padded" }
|
13
|
+
text "I'm far away"
|
14
|
+
stroke_horizontal_line 50, 100
|
15
|
+
stroke_horizontal_line 50, 100, :at => 300
|
16
|
+
stroke_vertical_line 300, 50, :at => 250
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
+
require 'prawn'
|
3
|
+
|
4
|
+
class Array
|
5
|
+
def combine(arr)
|
6
|
+
output = []
|
7
|
+
self.each do |i1|
|
8
|
+
arr.each do |i2|
|
9
|
+
output += [[i1,i2]]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
output
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def recurse_bounding_box(pdf, max_depth=5, depth=1)
|
17
|
+
box = pdf.bounds
|
18
|
+
width = (box.width-15)/2
|
19
|
+
height = (box.height-15)/2
|
20
|
+
left_top_corners = [5, box.right-width-5].combine [box.top-5, height+5]
|
21
|
+
left_top_corners.each do |lt|
|
22
|
+
pdf.bounding_box(lt, :width=>width, :height=>height) do
|
23
|
+
pdf.stroke_rectangle [0,height], width, height
|
24
|
+
recurse_bounding_box(pdf, max_depth, depth+1) if depth<max_depth
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
Prawn::Document.generate("russian_boxes.pdf") do |pdf|
|
31
|
+
recurse_bounding_box(pdf)
|
32
|
+
end
|
33
|
+
|
34
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require "prawn"
|
5
|
+
|
6
|
+
Prawn::Document.generate "hello.pdf" do
|
7
|
+
fill_color "0000ff"
|
8
|
+
text "Hello World", :at => [200,420], :size => 32, :rotate => 45
|
9
|
+
font "Times-Roman"
|
10
|
+
fill_color "ff0000"
|
11
|
+
text "Overcoming singular font limitation", :at => [5,5]
|
12
|
+
start_new_page
|
13
|
+
font "Courier"
|
14
|
+
text "Goodbye World", :at => [288,50]
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require "prawn"
|
5
|
+
|
6
|
+
Prawn::Document.generate "hello-ttf.pdf" do
|
7
|
+
fill_color "0000ff"
|
8
|
+
font "#{Prawn::BASEDIR}/data/fonts/comicsans.ttf"
|
9
|
+
text "Hello World", :at => [200,720], :size => 32
|
10
|
+
|
11
|
+
font "#{Prawn::BASEDIR}/data/fonts/Chalkboard.ttf"
|
12
|
+
|
13
|
+
pad(20) do
|
14
|
+
text "This is chalkboard wrapping " * 20
|
15
|
+
end
|
16
|
+
end
|
data/examples/sjis.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# Tests passing non utf-8 data into Prawns text function. Should
|
4
|
+
# be transparently converted to utf-8 and rendered as usual.
|
5
|
+
#
|
6
|
+
# NOTE: only works on ruby1.9 compatible VMs, and requires the current
|
7
|
+
# font to include japanese glyphs. On 1.8.x comaptible VMs, an exception
|
8
|
+
# will be raised.
|
9
|
+
|
10
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
11
|
+
require "prawn"
|
12
|
+
|
13
|
+
ruby_19 do
|
14
|
+
datafile = File.join(File.dirname(__FILE__), "..", "data", "shift_jis_text.txt")
|
15
|
+
sjis_str = File.open(datafile, "r:shift_jis") { |f| f.gets }
|
16
|
+
|
17
|
+
Prawn::Document.generate("sjis.pdf") do
|
18
|
+
font "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
|
19
|
+
text sjis_str
|
20
|
+
end
|
21
|
+
end
|
data/examples/span.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require "prawn"
|
5
|
+
|
6
|
+
Prawn::Document.generate("span.pdf") do
|
7
|
+
|
8
|
+
# Spans will typically be used outside of bounding boxes as a way to build
|
9
|
+
# single columns of flowing text that span across pages.
|
10
|
+
#
|
11
|
+
span(350, :position => :center) do
|
12
|
+
text "Here's some centered text in a 350 point column. " * 100
|
13
|
+
end
|
14
|
+
|
15
|
+
# Spans are not really compatible with bounding boxes because they break
|
16
|
+
# the nesting chain and also may position text outside of the bounding box
|
17
|
+
# boundaries, but sometimes you may wish to use them anyway for convenience
|
18
|
+
# Here's an example of how to do that dynamically.
|
19
|
+
#
|
20
|
+
bounding_box([50,300], :width => 400) do
|
21
|
+
text "Here's some default bounding box text. " * 10
|
22
|
+
span(bounds.width,
|
23
|
+
:position => bounds.absolute_left - margin_box.absolute_left) do
|
24
|
+
text "The rain in spain falls mainly on the plains. " * 300
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/examples/table.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require "prawn"
|
5
|
+
|
6
|
+
Prawn::Document.generate("table.pdf") do
|
7
|
+
font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
|
8
|
+
table [["ὕαλον ϕαγεῖν", "baaar", "1" ],
|
9
|
+
["This is","a sample", "2" ],
|
10
|
+
["Table", "dont\ncha\nknow?", "3" ],
|
11
|
+
[ "It", "Rules", "4" ],
|
12
|
+
[ "It", "Rules", "4" ],
|
13
|
+
[ "It", "Rules", "4123231" ],
|
14
|
+
[ "It", "Rules", "22.5" ],
|
15
|
+
[ "It", "Rules", "4" ],
|
16
|
+
[ "It", "Rules", "4" ],
|
17
|
+
[ "It", "Rules", "4" ],
|
18
|
+
[ "It", "Rules", "4" ],
|
19
|
+
[ "It", "Rules", "4" ],
|
20
|
+
[ "It", "Rules\nwith an iron fist", "x" ],
|
21
|
+
[ "It", "Rules", "4" ],
|
22
|
+
[ "It", "Rules", "4" ],
|
23
|
+
[ "It", "Rules", "4" ],
|
24
|
+
[ "It", "Rules", "4" ],
|
25
|
+
[ "It", "Rules", "4" ],
|
26
|
+
[ "It", "Rules", "4" ],
|
27
|
+
[ "It", "Rules", "4" ],
|
28
|
+
[ "It", "Rules", "4" ],
|
29
|
+
[ "It", "Rules", "4" ]],
|
30
|
+
|
31
|
+
:font_size => 24,
|
32
|
+
:horizontal_padding => 10,
|
33
|
+
:vertical_padding => 3,
|
34
|
+
:border_width => 2,
|
35
|
+
:position => :center,
|
36
|
+
:headers => ["Column A","Column B","#"],
|
37
|
+
:align => {1 => :center},
|
38
|
+
:align_headers => :center
|
39
|
+
|
40
|
+
text "This should appear in the original font size, just below the table"
|
41
|
+
move_down 10
|
42
|
+
|
43
|
+
table [[ "Wide", "columns", "streeetch"],
|
44
|
+
["are","mighty fine", "streeeeeeeech"]],
|
45
|
+
:widths => { 0 => 200, 1 => 250 }, :position => 5
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require "prawn"
|
5
|
+
|
6
|
+
Prawn::Document.generate "table_header_color.pdf" do
|
7
|
+
table [ ['01/01/2008', 'John Doe', '4.2', '125.00', '525.00'],
|
8
|
+
['01/12/2008', 'Jane Doe', '3.2', '75.50', '241.60'] ] * 20,
|
9
|
+
:position => :center,
|
10
|
+
:headers => ['Date', 'Employee', 'Hours', 'Rate', 'Total'],
|
11
|
+
:widths => { 0 => 75, 1 => 100, 2 => 50, 3 => 50, 4 => 50},
|
12
|
+
:border_style => :grid,
|
13
|
+
:header_color => 'f07878',
|
14
|
+
:header_text_color => "990000",
|
15
|
+
:row_colors => ["FFCCFF","CCFFCC"]
|
16
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require "prawn"
|
5
|
+
|
6
|
+
content = <<-EOS
|
7
|
+
How does
|
8
|
+
Prawn deal with
|
9
|
+
white
|
10
|
+
space
|
11
|
+
|
12
|
+
and
|
13
|
+
|
14
|
+
line
|
15
|
+
breaks?
|
16
|
+
EOS
|
17
|
+
|
18
|
+
poem = <<-EOS
|
19
|
+
GOOD-BYE
|
20
|
+
|
21
|
+
Good-bye, proud world! I'm going home: Thou art not my friend, and I'm not thine. Long through thy weary crowds I roam; A river-ark on the ocean brine, Long I've been tossed like the driven foam: But now, proud world! I'm going home.
|
22
|
+
|
23
|
+
Good-bye to Flattery's fawning face; To Grandeur with his wise grimace; To upstart Wealth's averted eye; To supple Office, low and high; To crowded halls, to court and street; To frozen hearts and hasting feet; To those who go, and those who come; Good-bye, proud world! I'm going home.
|
24
|
+
|
25
|
+
I am going to my own hearth-stone, Bosomed in yon green hills alone,-- secret nook in a pleasant land, Whose groves the frolic fairies planned; Where arches green, the livelong day, Echo the blackbird's roundelay, And vulgar feet have never trod A spot that is sacred to thought and God.
|
26
|
+
|
27
|
+
O, when I am safe in my sylvan home, I tread on the pride of Greece and Rome; And when I am stretched beneath the pines, Where the evening star so holy shines, I laugh at the lore and the pride of man, At the sophist schools and the learned clan; For what are they all, in their high conceit, When man in the bush with God may meet?
|
28
|
+
EOS
|
29
|
+
|
30
|
+
overflow = "This text should flow gracefully onto the next page, like a stream"+
|
31
|
+
" flows elegantly from a mountain lake down into the village below."
|
32
|
+
|
33
|
+
Prawn::Document.generate("flow.pdf") do |pdf|
|
34
|
+
|
35
|
+
pdf.font "Times-Roman"
|
36
|
+
pdf.stroke_line [pdf.bounds.left, pdf.bounds.top],
|
37
|
+
[pdf.bounds.right, pdf.bounds.top]
|
38
|
+
|
39
|
+
pdf.text content, :size => 10
|
40
|
+
|
41
|
+
pdf.bounding_box([100,600], :width => 200, :height => 525) do
|
42
|
+
pdf.stroke_line [pdf.bounds.left, pdf.bounds.top],
|
43
|
+
[pdf.bounds.right, pdf.bounds.top]
|
44
|
+
pdf.text poem, :size => 12
|
45
|
+
end
|
46
|
+
|
47
|
+
pdf.bounding_box([325,600], :width => 200, :height => 525) do
|
48
|
+
pdf.stroke_line [pdf.bounds.left, pdf.bounds.top],
|
49
|
+
[pdf.bounds.right, pdf.bounds.top]
|
50
|
+
pdf.text poem.reverse, :size => 12
|
51
|
+
end
|
52
|
+
|
53
|
+
pdf.text overflow * 10, :size => 14
|
54
|
+
|
55
|
+
pdf.text "Hooray! We've conquered the evil PDF gods", :size => 36
|
56
|
+
|
57
|
+
pdf.bounding_box([100,450], :width => 300) do
|
58
|
+
pdf.stroke_line [pdf.bounds.left, pdf.bounds.top],
|
59
|
+
[pdf.bounds.right, pdf.bounds.top]
|
60
|
+
pdf.text poem, :size => 12, :spacing => 5
|
61
|
+
end
|
62
|
+
|
63
|
+
pdf.text "And this text automatically goes below the poem", :size => 18
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require "prawn"
|
5
|
+
require "rubygems"
|
6
|
+
|
7
|
+
headers, body = nil, nil
|
8
|
+
|
9
|
+
ruby_18 do
|
10
|
+
require "fastercsv"
|
11
|
+
headers, *body = FasterCSV.read("#{Prawn::BASEDIR}/examples/addressbook.csv")
|
12
|
+
end
|
13
|
+
|
14
|
+
ruby_19 do
|
15
|
+
require "csv"
|
16
|
+
headers, *body = CSV.read("#{Prawn::BASEDIR}/examples/addressbook.csv")
|
17
|
+
headers.map! { |e| e.encode("UTF-8") }
|
18
|
+
body.map! { |e| e.map! { |x| x.encode("UTF-8") } }
|
19
|
+
end
|
20
|
+
|
21
|
+
Prawn::Document.generate("top_and_bottom_cells.pdf", :page_layout => :portrait) do
|
22
|
+
|
23
|
+
table(body, :headers => headers, :align => :center, :border_style => :top_and_bottom)
|
24
|
+
|
25
|
+
move_down(50)
|
26
|
+
|
27
|
+
table(body, :headers => headers, :align => :center, :border_style => :top_and_bottom, :header_border_style => :sides)
|
28
|
+
|
29
|
+
move_down(50)
|
30
|
+
|
31
|
+
table(body, :headers => headers, :align => :center, :border_style => :grid, :header_border_style => :bottom_only)
|
32
|
+
|
33
|
+
|
34
|
+
# cell([500,300], :text => "This free flowing textbox shows how you can use Prawn's "+
|
35
|
+
# "cells outside of a table with ease. Think of a 'cell' as " +
|
36
|
+
# "simply a limited purpose bounding box that is meant for laying " +
|
37
|
+
# "out blocks of text and optionally placing a border around it",
|
38
|
+
# :width => 225, :padding => 10, :border_width => 2, :border_style => :top_and_bottom)
|
39
|
+
|
40
|
+
end
|
data/examples/utf8.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require "prawn"
|
5
|
+
|
6
|
+
Prawn::Document.generate("utf8.pdf") do
|
7
|
+
font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
|
8
|
+
text "ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει." * 20
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
|
data/lib/prawn.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# prawn.rb : A library for PDF generation in Ruby
|
4
|
+
#
|
5
|
+
# Copyright April 2008, Gregory Brown. All Rights Reserved.
|
6
|
+
#
|
7
|
+
# This is free software. Please see the LICENSE and COPYING files for details.
|
8
|
+
|
9
|
+
%w[ttfunk/lib].each do |dep|
|
10
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + "/../vendor/#{dep}")
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'ttfunk'
|
14
|
+
|
15
|
+
module Prawn
|
16
|
+
file = __FILE__
|
17
|
+
file = File.readlink(file) if File.symlink?(file)
|
18
|
+
dir = File.dirname(file)
|
19
|
+
|
20
|
+
# The base source directory for Prawn as installed on the system
|
21
|
+
BASEDIR = File.expand_path(File.join(dir, '..'))
|
22
|
+
|
23
|
+
extend self
|
24
|
+
|
25
|
+
attr_accessor :debug
|
26
|
+
|
27
|
+
def verify_options(accepted,actual) #:nodoc:
|
28
|
+
return unless debug || $DEBUG
|
29
|
+
require "set"
|
30
|
+
unless (act=Set[*actual.keys]).subset?(acc=Set[*accepted])
|
31
|
+
raise Prawn::Errors::UnknownOption,
|
32
|
+
"\nDetected unknown option(s): #{(act - acc).to_a.inspect}\n" <<
|
33
|
+
"Accepted options are: #{accepted.inspect}"
|
34
|
+
end
|
35
|
+
yield if block_given?
|
36
|
+
end
|
37
|
+
|
38
|
+
module Configurable #:nodoc:
|
39
|
+
def configuration(*args)
|
40
|
+
@config ||= Marshal.load(Marshal.dump(default_configuration))
|
41
|
+
if Hash === args[0]
|
42
|
+
@config.update(args[0])
|
43
|
+
elsif args.length > 1
|
44
|
+
@config.values_at(*args)
|
45
|
+
elsif args.length == 1
|
46
|
+
@config[args[0]]
|
47
|
+
else
|
48
|
+
@config
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
alias_method :C, :configuration
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
require "prawn/compatibility"
|
57
|
+
require "prawn/errors"
|
58
|
+
require "prawn/pdf_object"
|
59
|
+
require "prawn/graphics"
|
60
|
+
require "prawn/images"
|
61
|
+
require "prawn/images/jpg"
|
62
|
+
require "prawn/images/png"
|
63
|
+
require "prawn/document"
|
64
|
+
require "prawn/reference"
|
65
|
+
require "prawn/font"
|
66
|
+
require "prawn/encoding"
|
67
|
+
require "prawn/measurements"
|