prawn-core 0.5.0.1 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README +21 -6
- data/Rakefile +1 -1
- data/examples/bounding_box/bounding_boxes.rb +1 -2
- data/examples/bounding_box/indentation.rb +34 -0
- data/examples/bounding_box/russian_boxes.rb +1 -2
- data/examples/column_box/column_box_example.rb +1 -2
- data/examples/example_helper.rb +3 -0
- data/examples/general/background.rb +11 -8
- data/examples/general/canvas.rb +1 -2
- data/examples/general/measurement_units.rb +1 -2
- data/examples/general/metadata-info.rb +1 -2
- data/examples/general/multi_page_layout.rb +1 -2
- data/examples/general/page_geometry.rb +1 -2
- data/examples/graphics/basic_images.rb +1 -2
- data/examples/graphics/cmyk.rb +1 -2
- data/examples/graphics/curves.rb +1 -2
- data/examples/graphics/hexagon.rb +1 -2
- data/examples/graphics/image_fit.rb +1 -2
- data/examples/graphics/image_flow.rb +1 -2
- data/examples/graphics/image_position.rb +1 -2
- data/examples/graphics/line.rb +1 -2
- data/examples/graphics/png_types.rb +1 -2
- data/examples/graphics/polygons.rb +1 -2
- data/examples/graphics/remote_images.rb +2 -2
- data/examples/graphics/ruport_style_helpers.rb +1 -2
- data/examples/graphics/stroke_bounds.rb +1 -2
- data/examples/m17n/chinese_text_wrapping.rb +5 -6
- data/examples/m17n/euro.rb +1 -2
- data/examples/m17n/sjis.rb +1 -2
- data/examples/m17n/utf8.rb +1 -2
- data/examples/m17n/win_ansi_charset.rb +1 -2
- data/examples/text/alignment.rb +1 -2
- data/examples/text/dfont.rb +1 -2
- data/examples/text/family_based_styling.rb +1 -2
- data/examples/text/font_calculations.rb +1 -2
- data/examples/text/font_size.rb +1 -2
- data/examples/text/kerning.rb +1 -2
- data/examples/text/simple_text.rb +1 -2
- data/examples/text/simple_text_ttf.rb +1 -2
- data/examples/text/span.rb +1 -2
- data/examples/text/text_box.rb +3 -4
- data/examples/text/text_flow.rb +2 -3
- data/lib/prawn/core.rb +12 -5
- data/lib/prawn/document/annotations.rb +15 -14
- data/lib/prawn/document/bounding_box.rb +36 -28
- data/lib/prawn/document/column_box.rb +15 -0
- data/lib/prawn/document/destinations.rb +10 -0
- data/lib/prawn/document/internals.rb +4 -0
- data/lib/prawn/document/page_geometry.rb +7 -3
- data/lib/prawn/document/text.rb +6 -15
- data/lib/prawn/document.rb +21 -2
- data/lib/prawn/errors.rb +2 -2
- data/lib/prawn/font/dfont.rb +3 -0
- data/lib/prawn/font/ttf.rb +2 -0
- data/lib/prawn/font.rb +2 -0
- data/lib/prawn/graphics.rb +0 -1
- data/lib/prawn/images/jpg.rb +2 -1
- data/lib/prawn/images/png.rb +2 -0
- data/spec/bounding_box_spec.rb +35 -0
- data/spec/font_spec.rb +1 -2
- metadata +4 -2
data/LICENSE
CHANGED
data/README
CHANGED
@@ -3,9 +3,12 @@
|
|
3
3
|
Prawn is a PDF writing library for Ruby designed to be tiny, fast, and nimble,
|
4
4
|
just like the majestic sea creature.
|
5
5
|
|
6
|
-
Development on this library
|
7
|
-
donated to the Ruby Mendicant project
|
8
|
-
|
6
|
+
Development on this library was initially made possible thanks to
|
7
|
+
the many people who donated to the Ruby Mendicant project:
|
8
|
+
http://rubymendicant.wikidot.com
|
9
|
+
|
10
|
+
The project is currently maintained by Gregory Brown, with lots of help from
|
11
|
+
the community.
|
9
12
|
|
10
13
|
== Quick Start
|
11
14
|
|
@@ -94,17 +97,29 @@ http://prawn.majesticseacreature.com
|
|
94
97
|
|
95
98
|
=== Examples:
|
96
99
|
|
97
|
-
http://github.com/sandal/prawn/tree/
|
100
|
+
http://github.com/sandal/prawn/tree/stable/examples
|
101
|
+
|
102
|
+
For tables and grid based layout:
|
103
|
+
|
104
|
+
http://github.com/sandal/prawn-layout/tree/stable/examples
|
105
|
+
|
106
|
+
For inline styling and advanced formatting:
|
107
|
+
|
108
|
+
http://github.com/sandal/prawn-format/tree/stable/examples
|
98
109
|
|
99
|
-
(or gem unpack prawn, if you want to run them locally)
|
110
|
+
(or gem unpack prawn-core, prawn-format, and prawn-layout if you want to run them locally)
|
100
111
|
|
101
112
|
=== Bug Tracker / Wiki:
|
102
113
|
|
103
114
|
http://github.com/sandal/prawn/issues
|
115
|
+
http://github.com/sandal/prawn-layout/issues
|
116
|
+
http://github.com/sandal/prawn-format/issues
|
104
117
|
|
105
|
-
===
|
118
|
+
=== Source Code:
|
106
119
|
|
107
120
|
http://github.com/sandal/prawn
|
121
|
+
http://github.com/sandal/prawn-layout
|
122
|
+
http://github.com/sandal/prawn-format
|
108
123
|
|
109
124
|
=== Mailing List:
|
110
125
|
|
data/Rakefile
CHANGED
@@ -3,8 +3,7 @@
|
|
3
3
|
# This example demonstrates the basic functionality of Prawn's bounding boxes.
|
4
4
|
# Note that top level bounding boxes are positioned relative to the margin_box.
|
5
5
|
#
|
6
|
-
|
7
|
-
require 'prawn/core'
|
6
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
8
7
|
|
9
8
|
Prawn::Document.generate("bounding_boxes.pdf") do
|
10
9
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# This example demonstrates the basic functionality of Prawn's bounding boxes.
|
4
|
+
# Note that top level bounding boxes are positioned relative to the margin_box.
|
5
|
+
#
|
6
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
7
|
+
|
8
|
+
Prawn::Document.generate("indentation.pdf") do
|
9
|
+
|
10
|
+
text "No indentation"
|
11
|
+
indent(20) do
|
12
|
+
text "Some indentation"
|
13
|
+
# Generates a box with a top-left of [100,600] and a top-right of [300,600]
|
14
|
+
# The box automatically expands as the cursor moves down the page. Notice
|
15
|
+
# that the final coordinates are outlined by a top and bottom line drawn
|
16
|
+
# relatively using calculations from +bounds+.
|
17
|
+
#
|
18
|
+
bounding_box [100,600], :width => 200 do
|
19
|
+
text "A little more indentation"
|
20
|
+
indent(20) do
|
21
|
+
text "And some more indentation"
|
22
|
+
indent(20) do
|
23
|
+
text "And some deeper indentation"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
text "Some indentation"
|
28
|
+
end
|
29
|
+
indent(10) do
|
30
|
+
text "A bit of indentation"
|
31
|
+
end
|
32
|
+
|
33
|
+
text "No indentation"
|
34
|
+
end
|
@@ -4,8 +4,7 @@
|
|
4
4
|
# can simplify calculations. See the other files in examples/bounding_box
|
5
5
|
# for more basic uses.
|
6
6
|
|
7
|
-
|
8
|
-
require 'prawn/core'
|
7
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
9
8
|
|
10
9
|
class Array
|
11
10
|
def combine(arr)
|
@@ -2,8 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# Text should flow between columns before wrapping to the next page, like a printed newspaper.
|
4
4
|
#
|
5
|
-
|
6
|
-
require "prawn/core"
|
5
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
7
6
|
|
8
7
|
paragraphs = []
|
9
8
|
paragraphs << <<-ONE
|
@@ -4,17 +4,20 @@
|
|
4
4
|
# generating a new Document. Image is assumed to be pre-fit for your page
|
5
5
|
# size, and will not be rescaled.
|
6
6
|
#
|
7
|
-
|
8
|
-
require "prawn/core"
|
7
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
9
8
|
|
10
9
|
img = "#{Prawn::BASEDIR}/data/images/letterhead.jpg"
|
11
10
|
|
12
11
|
Prawn::Document.generate("background.pdf", :background => img) do
|
13
|
-
|
14
|
-
|
15
|
-
text_options.update(:size => 12, :align => :left, :spacing => 2)
|
12
|
+
text "My report caption", :size => 18, :align => :right
|
13
|
+
|
16
14
|
move_down font.height * 2
|
17
|
-
|
15
|
+
|
16
|
+
text "Here is my text explaning this report. " * 20,
|
17
|
+
:size => 12, :align => :left, :leading => 2
|
18
|
+
|
18
19
|
move_down font.height
|
19
|
-
|
20
|
-
|
20
|
+
|
21
|
+
text "I'm using a soft background. " * 40,
|
22
|
+
:size => 12, :align => :left, :leading => 2
|
23
|
+
end
|
data/examples/general/canvas.rb
CHANGED
@@ -3,8 +3,7 @@
|
|
3
3
|
# Demonstrates how to enable absolute positioning in Prawn by temporarily
|
4
4
|
# removing the margin_box via Document#canvas()
|
5
5
|
#
|
6
|
-
|
7
|
-
require "prawn/core"
|
6
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
8
7
|
|
9
8
|
Prawn::Document.generate("canvas.pdf") do
|
10
9
|
canvas do
|
@@ -5,8 +5,7 @@
|
|
5
5
|
# its particular implementation, though some might find that interesting as
|
6
6
|
# well.
|
7
7
|
#
|
8
|
-
|
9
|
-
require "prawn/core"
|
8
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
10
9
|
|
11
10
|
require "prawn/measurement_extensions"
|
12
11
|
|
@@ -3,8 +3,7 @@
|
|
3
3
|
# Demonstrates how to set metadata properties via the info option
|
4
4
|
# It allows one to specify no standard properties
|
5
5
|
#
|
6
|
-
|
7
|
-
require "prawn/core"
|
6
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
8
7
|
|
9
8
|
Prawn::Document.generate "metadata-info.pdf",
|
10
9
|
:info => {
|
@@ -3,8 +3,7 @@
|
|
3
3
|
# This demonstrates that Prawn can modify page size, margins and layout for
|
4
4
|
# each individual page, via Document#start_new_page()
|
5
5
|
#
|
6
|
-
|
7
|
-
require "prawn/core"
|
6
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
8
7
|
|
9
8
|
Prawn::Document.generate("multi-layout.pdf", :page_layout => :landscape) do |pdf|
|
10
9
|
pdf.text "This is on a landscaped page"
|
@@ -4,8 +4,7 @@
|
|
4
4
|
# documents. The style used here is a bit out of date, see
|
5
5
|
# multi_page_layout.rb for a more modern example.
|
6
6
|
#
|
7
|
-
|
8
|
-
require "prawn/core"
|
7
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
9
8
|
|
10
9
|
def pdf(*options)
|
11
10
|
Prawn::Document.new(*options)
|
@@ -4,8 +4,7 @@
|
|
4
4
|
# For positioning images alongside flowing text, see the image_flow.rb
|
5
5
|
# example.
|
6
6
|
#
|
7
|
-
|
8
|
-
require "prawn/core"
|
7
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
9
8
|
|
10
9
|
Prawn::Document.generate("basic_images.pdf", :page_layout => :landscape) do
|
11
10
|
stef = "#{Prawn::BASEDIR}/data/images/stef.jpg"
|
data/examples/graphics/cmyk.rb
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# Demonstrates Prawn's support for CMYK images and colors.
|
4
4
|
#
|
5
|
-
|
6
|
-
require "prawn/core"
|
5
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
7
6
|
|
8
7
|
Prawn::Document.generate("cmyk.pdf", :page_layout => :landscape) do
|
9
8
|
fill_color 50, 100, 0, 0
|
data/examples/graphics/curves.rb
CHANGED
@@ -4,8 +4,7 @@
|
|
4
4
|
# The image will be scaled down to fit within the box, while preserving
|
5
5
|
# the aspect ratio.
|
6
6
|
#
|
7
|
-
|
8
|
-
require "prawn/core"
|
7
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
9
8
|
|
10
9
|
Prawn::Document.generate("image_fit.pdf", :page_layout => :landscape) do
|
11
10
|
|
@@ -5,8 +5,7 @@
|
|
5
5
|
# useful when used in combination with flowing text, where the exact final
|
6
6
|
# position of the image is not known ahead of time.
|
7
7
|
#
|
8
|
-
|
9
|
-
require "prawn/core"
|
8
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
10
9
|
|
11
10
|
Prawn::Document.generate("image-flow.pdf", :page_layout => :landscape) do
|
12
11
|
self.font_size = 8
|
@@ -2,8 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# Demonstrates vertical and horizontal positioning of images.
|
4
4
|
#
|
5
|
-
|
6
|
-
require "prawn/core"
|
5
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
7
6
|
|
8
7
|
Prawn::Document.generate("image_position.pdf", :page_layout => :landscape) do
|
9
8
|
|
data/examples/graphics/line.rb
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# The very first Prawn example. Here for nostalgia's sake.
|
4
4
|
#
|
5
|
-
|
6
|
-
require "prawn/core"
|
5
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
7
6
|
|
8
7
|
pdf = Prawn::Document.new
|
9
8
|
pdf.line_width = 10
|
@@ -3,8 +3,7 @@
|
|
3
3
|
# PNG files come in different flavours - 5 of them. This example embeds
|
4
4
|
# one of each type as proof that they all work.
|
5
5
|
#
|
6
|
-
|
7
|
-
require "prawn/core"
|
6
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
8
7
|
|
9
8
|
images = [
|
10
9
|
["Type 0", "#{Prawn::BASEDIR}/data/images/web-links.png"],
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# Demonstrates how to use open-uri and Document#image to embed remote image
|
4
4
|
# files.
|
5
5
|
#
|
6
|
-
|
7
|
-
|
6
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
7
|
+
|
8
8
|
require "open-uri"
|
9
9
|
|
10
10
|
Prawn::Document.generate("remote_images.pdf") do
|
@@ -3,8 +3,7 @@
|
|
3
3
|
# These helpers will be familiar to Ruport users, and now are supported
|
4
4
|
# directly in Prawn. Run the example to see how they work.
|
5
5
|
#
|
6
|
-
|
7
|
-
require "prawn/core"
|
6
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
8
7
|
|
9
8
|
# Demonstrates some features stolen from Ruport::Formatter::PDF
|
10
9
|
Prawn::Document.generate("ruport.pdf") do
|
@@ -8,8 +8,7 @@
|
|
8
8
|
# Feature borrowed from Josh Knowle's pt at:
|
9
9
|
# http://github.com/joshknowles/pt/tree/master
|
10
10
|
#
|
11
|
-
|
12
|
-
require 'prawn/core'
|
11
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
13
12
|
|
14
13
|
Prawn::Document.generate("stroke_bounds.pdf") do
|
15
14
|
stroke_bounds
|
@@ -3,18 +3,17 @@
|
|
3
3
|
# Some text is not usefully wrapped by our naive_wrap which depends on
|
4
4
|
# spaces. This example shows how to wrap by character instead.
|
5
5
|
#
|
6
|
-
|
7
|
-
require "prawn/core"
|
6
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
8
7
|
|
9
8
|
start = Time.now
|
10
9
|
Prawn::Document.generate("chinese_flow.pdf") do
|
11
10
|
font "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
|
12
|
-
|
11
|
+
font_size 16
|
12
|
+
|
13
13
|
long_text = "更可怕的是,同质化竞争对手可以按照URL中后面这个ID来遍历您的DB中的内容,写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事,这样的话,你就非常被动了。写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事"
|
14
|
-
text long_text
|
14
|
+
text long_text, :wrap => :character
|
15
15
|
|
16
16
|
# be sure to restore space based wrapping when dealing with latin scripts
|
17
|
-
text_options.update(:wrap => :spaces)
|
18
17
|
long_text = "Text with some spaces " * 25
|
19
18
|
text long_text
|
20
|
-
end
|
19
|
+
end
|
data/examples/m17n/euro.rb
CHANGED
@@ -8,8 +8,7 @@
|
|
8
8
|
# If you need precision spacing, use a TTF file instead and the issue will
|
9
9
|
# go away.
|
10
10
|
#
|
11
|
-
|
12
|
-
require "prawn/core"
|
11
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
13
12
|
|
14
13
|
Prawn::Document.generate "euro.pdf" do
|
15
14
|
text "A Euro! € ©", :size => 32
|
data/examples/m17n/sjis.rb
CHANGED
@@ -10,8 +10,7 @@
|
|
10
10
|
# font to include japanese glyphs. On 1.8.x comaptible VMs, an exception
|
11
11
|
# will be raised.
|
12
12
|
|
13
|
-
|
14
|
-
require "prawn/core"
|
13
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
15
14
|
|
16
15
|
begin
|
17
16
|
ruby_19 do
|
data/examples/m17n/utf8.rb
CHANGED
@@ -3,8 +3,7 @@
|
|
3
3
|
# Shows that Prawn works out of the box with UTF-8 text, so long as you use
|
4
4
|
# a TTF file with the necessary glyphs for your content.
|
5
5
|
#
|
6
|
-
|
7
|
-
require "prawn/core"
|
6
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
8
7
|
|
9
8
|
Prawn::Document.generate("utf8.pdf") do
|
10
9
|
font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
|
@@ -4,8 +4,7 @@
|
|
4
4
|
# in fonts, along with their character widths and WinAnsi codes. Be sure
|
5
5
|
# to pass these glyphs as UTF-8, and Prawn will transcode them for you.
|
6
6
|
#
|
7
|
-
|
8
|
-
require 'prawn/core'
|
7
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
9
8
|
|
10
9
|
FONT_SIZE = 9.5
|
11
10
|
|
data/examples/text/alignment.rb
CHANGED
@@ -3,8 +3,7 @@
|
|
3
3
|
# This example demonstrates usage of Document#text with the :align option.
|
4
4
|
# Available options are :left, :right, and :center, with :left as default.
|
5
5
|
#
|
6
|
-
|
7
|
-
require "prawn/core"
|
6
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
8
7
|
|
9
8
|
Prawn::Document.generate("alignment.pdf") do
|
10
9
|
text "This text should be left aligned"
|
data/examples/text/dfont.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
require "prawn/core"
|
3
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
5
4
|
|
6
5
|
DFONT_FILE = "#{Prawn::BASEDIR}/data/fonts/Action Man.dfont"
|
7
6
|
puts "There are #{Prawn::Font::DFont.font_count(DFONT_FILE)} fonts in #{DFONT_FILE}:"
|
@@ -4,8 +4,7 @@
|
|
4
4
|
# If you are working with TTF fonts, you'll want to check out the
|
5
5
|
# documentation for Document#font_families and register your fonts with it.
|
6
6
|
#
|
7
|
-
|
8
|
-
require "prawn/core"
|
7
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
9
8
|
|
10
9
|
Prawn::Document.generate("family_style.pdf") do
|
11
10
|
["Courier","Helvetica","Times-Roman"].each do |f|
|
@@ -4,8 +4,7 @@
|
|
4
4
|
# meant to assist those that need to do advanced positioning calculations.
|
5
5
|
# Run the example for a clearer picture of how things work
|
6
6
|
#
|
7
|
-
|
8
|
-
require 'prawn/core'
|
7
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
9
8
|
|
10
9
|
Prawn::Document.generate('font_calculations.pdf') do
|
11
10
|
|
data/examples/text/font_size.rb
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# This example shows the many ways of setting font sizes in Prawn
|
4
4
|
#
|
5
|
-
|
6
|
-
require "prawn/core"
|
5
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
7
6
|
|
8
7
|
Prawn::Document.generate "font_size.pdf", :page_size => "A4" do
|
9
8
|
|
data/examples/text/kerning.rb
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# Demonstration of enabling and disabling kerning support
|
4
4
|
#
|
5
|
-
|
6
|
-
require "prawn/core"
|
5
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
7
6
|
|
8
7
|
Prawn::Document.generate "kerning.pdf" do
|
9
8
|
text "To kern?", :at => [200,720], :size => 24, :kerning => true
|
@@ -3,8 +3,7 @@
|
|
3
3
|
# An early example of basic text generation at absolute positions.
|
4
4
|
# Mostly kept for nostalgia.
|
5
5
|
#
|
6
|
-
|
7
|
-
require "prawn/core"
|
6
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
8
7
|
|
9
8
|
Prawn::Document.generate "simple_text.pdf" do
|
10
9
|
fill_color "0000ff"
|
@@ -2,8 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# An early example of TTF font embedding. Mostly kept for nostalgia's sake.
|
4
4
|
#
|
5
|
-
|
6
|
-
require "prawn/core"
|
5
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
7
6
|
|
8
7
|
Prawn::Document.generate "simple_text_ttf.pdf" do
|
9
8
|
fill_color "0000ff"
|
data/examples/text/span.rb
CHANGED
@@ -3,8 +3,7 @@
|
|
3
3
|
# Demonstration of Document#span, which is used for generating flowing
|
4
4
|
# columns of text.
|
5
5
|
#
|
6
|
-
|
7
|
-
require "prawn/core"
|
6
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
8
7
|
|
9
8
|
Prawn::Document.generate("span.pdf") do
|
10
9
|
|
data/examples/text/text_box.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# A text box is positioned by a top-left corner, width, and height and is
|
4
|
-
# essentially an invisible rectangle that the text
|
4
|
+
# essentially an invisible rectangle that the text will flow within. If the
|
5
5
|
# text exceeds the boundaries, it is either truncated, replaced with some
|
6
6
|
# ellipses, or set to expand beyond the bottom boundary.
|
7
7
|
#
|
8
|
-
|
9
|
-
require 'prawn/core'
|
8
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
10
9
|
|
11
10
|
Prawn::Document.generate("text_box.pdf") do
|
12
11
|
|
@@ -23,4 +22,4 @@ Prawn::Document.generate("text_box.pdf") do
|
|
23
22
|
move_down 20
|
24
23
|
|
25
24
|
text_box "Oh hai text box. " * 100, :overflow => :expand
|
26
|
-
end
|
25
|
+
end
|
data/examples/text/text_flow.rb
CHANGED
@@ -3,8 +3,7 @@
|
|
3
3
|
# Basic text flowing example including the use of bounding boxes. A somewhat
|
4
4
|
# old example, mostly retained for nostalgia.
|
5
5
|
#
|
6
|
-
|
7
|
-
require "prawn/core"
|
6
|
+
require "#{File.dirname(__FILE__)}/../example_helper.rb"
|
8
7
|
|
9
8
|
content = <<-EOS
|
10
9
|
How does
|
@@ -60,7 +59,7 @@ Prawn::Document.generate("flow.pdf") do |pdf|
|
|
60
59
|
pdf.bounding_box([100,450], :width => 300) do
|
61
60
|
pdf.stroke_line [pdf.bounds.left, pdf.bounds.top],
|
62
61
|
[pdf.bounds.right, pdf.bounds.top]
|
63
|
-
pdf.text poem, :size => 10, :
|
62
|
+
pdf.text poem, :size => 10, :leading => 5
|
64
63
|
end
|
65
64
|
|
66
65
|
pdf.text "And this text automatically goes below the poem", :size => 18
|
data/lib/prawn/core.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
#
|
2
|
+
#
|
3
|
+
# Prawn : A library for PDF generation in Ruby
|
4
4
|
#
|
5
5
|
# Copyright April 2008, Gregory Brown. All Rights Reserved.
|
6
6
|
#
|
7
7
|
# This is free software. Please see the LICENSE and COPYING files for details.
|
8
|
-
|
8
|
+
|
9
9
|
%w[ttfunk/lib].each do |dep|
|
10
10
|
$LOAD_PATH.unshift(File.dirname(__FILE__) + "/../../vendor/#{dep}")
|
11
11
|
end
|
@@ -27,13 +27,20 @@ module Prawn
|
|
27
27
|
# The base source directory for Prawn as installed on the system
|
28
28
|
BASEDIR = File.expand_path(File.join(dir, '..', '..'))
|
29
29
|
|
30
|
-
VERSION = "0.5.
|
30
|
+
VERSION = "0.5.1"
|
31
31
|
|
32
32
|
extend self
|
33
33
|
|
34
34
|
# Whe set to true, Prawn will verify hash options to ensure only valid keys
|
35
35
|
# are used. Off by default.
|
36
|
-
#
|
36
|
+
#
|
37
|
+
# Example:
|
38
|
+
#
|
39
|
+
# >> Prawn::Document.new(:tomato => "Juicy")
|
40
|
+
# Prawn::Errors::UnknownOption:
|
41
|
+
# Detected unknown option(s): [:tomato]
|
42
|
+
# Accepted options are: [:page_size, :page_layout, :left_margin, ...]
|
43
|
+
#
|
37
44
|
attr_accessor :debug
|
38
45
|
|
39
46
|
def verify_options(accepted,actual) #:nodoc:
|