bounds method returns the current bounding box. This is
# useful because the Prawn::BoundinBox exposes some nice boundary
# helpers.
@@ -27,19 +27,19 @@ def print_coordinates
text "bottom: #{bounds.bottom}"
text "left: #{bounds.left}"
text "right: #{bounds.right}"
-
+
move_down 10
-
+
text "absolute top: #{sprintf "%.2f", bounds.absolute_top}"
text "absolute bottom: #{sprintf "%.2f", bounds.absolute_bottom}"
text "absolute left: #{sprintf "%.2f", bounds.absolute_left}"
text "absolute right: #{sprintf "%.2f", bounds.absolute_right}"
end
-
+
text "Margin box bounds:"
move_down 5
print_coordinates
-
+
bounding_box([250, cursor + 140], :width => 200, :height => 150) do
text "This bounding box bounds:"
move_down 5
diff --git a/manual/bounding_box/canvas.rb b/manual/bounding_box/canvas.rb
index e975dd4f5..cf3385b22 100644
--- a/manual/bounding_box/canvas.rb
+++ b/manual/bounding_box/canvas.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-#
+#
# The origin example already mentions that a new document already comes with
# a margin box whose bottom left corner is used as the origin for calculating
# coordinates.
diff --git a/manual/bounding_box/creation.rb b/manual/bounding_box/creation.rb
index f8db37cf1..823ec7390 100644
--- a/manual/bounding_box/creation.rb
+++ b/manual/bounding_box/creation.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-#
+#
# If you've read the basic concepts examples you probably know that the origin
# of a page is on the bottom left corner and that the content flows from top to
# bottom.
@@ -17,7 +17,7 @@
Prawn::Example.generate(filename) do
bounding_box([200, cursor - 100], :width => 200, :height => 100) do
text "Just your regular bounding box"
-
+
transparent(0.5) { stroke_bounds }
end
end
diff --git a/manual/bounding_box/indentation.rb b/manual/bounding_box/indentation.rb
index 9066b06ed..e280b826f 100644
--- a/manual/bounding_box/indentation.rb
+++ b/manual/bounding_box/indentation.rb
@@ -1,11 +1,11 @@
# encoding: utf-8
-#
+#
# Sometimes you just need to indent a portion of the contents of a bounding box, and
# using a nested bounding box is just pure overkill. The indent
# method is what you might need.
#
# Just provide a number for it to indent all content generated inside the
-# block.
+# block.
#
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))
@@ -17,28 +17,28 @@
text "Some indentation inside an indent block."
end
move_down 20
-
+
bounding_box([50, cursor], :width => 400, :height => cursor) do
transparent(0.5) { stroke_bounds }
-
+
move_down 10
text "No indentation inside this bounding box."
indent(40) do
text "Inside an indent block. And so is the following line:"
-
+
stroke_horizontal_rule
end
move_down 10
text "No indentation"
-
+
move_down 20
indent(60) do
text "Another indent block."
-
+
bounding_box([0, cursor], :width => 200) do
text "Note that this bounding box coordinates are relative to the " +
"indent block"
-
+
transparent(0.5) { stroke_bounds }
end
end
diff --git a/manual/bounding_box/nesting.rb b/manual/bounding_box/nesting.rb
index e36ff4fa0..f1500125c 100644
--- a/manual/bounding_box/nesting.rb
+++ b/manual/bounding_box/nesting.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-#
+#
# Normally when we provide the top left corner of a bounding box we
# express the coordinates are relative to the margin box. This is not the
# case when we have nested bounding boxes. Once nested the inner bounding box
@@ -18,26 +18,26 @@ def box_content(string)
text "#{string} height"
transparent(0.5) { stroke_bounds }
end
-
+
gap = 20
bounding_box([50, cursor], :width => 400, :height => 200) do
box_content("Fixed")
-
+
bounding_box([gap, cursor - gap], :width => 300) do
text "Stretchy height"
-
+
bounding_box([gap, bounds.top - gap], :width => 100) do
text "Stretchy height"
transparent(0.5) { dash(1); stroke_bounds; undash }
end
-
+
bounding_box([gap * 7, bounds.top - gap], :width => 100, :height => 50) do
box_content("Fixed")
end
-
+
transparent(0.5) { dash(1); stroke_bounds; undash }
end
-
+
bounding_box([gap, cursor - gap], :width => 300, :height => 50) do
box_content("Fixed")
end
diff --git a/manual/bounding_box/stretchy.rb b/manual/bounding_box/stretchy.rb
index 4f3e5ce2a..f539a47de 100644
--- a/manual/bounding_box/stretchy.rb
+++ b/manual/bounding_box/stretchy.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-#
+#
# Bounding Boxes accept an optional :height parameter. Unless it
# is provided the bounding box will be stretchy. It will expand the height to
# fit all content generated inside it.
@@ -13,19 +13,19 @@
bounding_box([0, y_position], :width => 200, :height => 100) do
text "This bounding box has a height of 100. If this text gets too large " +
"it will flow to the next page."
-
+
transparent(0.5) { stroke_bounds }
end
-
+
bounding_box([300, y_position], :width => 200) do
text "This bounding box has variable height. No matter how much text is " +
"written here, the height will expand to fit."
-
+
text " _" * 100
-
+
text " *" * 100
-
+
transparent(0.5) { stroke_bounds }
end
-
+
end
diff --git a/manual/document_and_page_options/background.rb b/manual/document_and_page_options/background.rb
index bf6602e26..063f39efa 100644
--- a/manual/document_and_page_options/background.rb
+++ b/manual/document_and_page_options/background.rb
@@ -2,7 +2,7 @@
#
# Pass an image path to the :background option and it will be used
# as the background for all pages.
-# This option can only be used on document creation.
+# This option can only be used on document creation.
#
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))
@@ -17,7 +17,7 @@
move_down font.height * 2
- text "Here is my text explaning this report. " * 20,
+ text "Here is my text explaning this report. " * 20,
:size => 12, :align => :left, :leading => 2
move_down font.height
diff --git a/manual/document_and_page_options/document_and_page_options.rb b/manual/document_and_page_options/document_and_page_options.rb
index 447f463d1..dbc44531e 100644
--- a/manual/document_and_page_options/document_and_page_options.rb
+++ b/manual/document_and_page_options/document_and_page_options.rb
@@ -12,7 +12,7 @@
{:name => "background", :eval_source => false, :full_source => true},
{:name => "metadata", :eval_source => false, :full_source => true}
]
-
+
) do
text "So far we've already seen how to create new documents and start new pages. This chapter expands on the previous examples by showing the options avialable. Some of the options are only available when creating new documents.
diff --git a/manual/document_and_page_options/metadata.rb b/manual/document_and_page_options/metadata.rb
index b863160c8..38b1509d8 100644
--- a/manual/document_and_page_options/metadata.rb
+++ b/manual/document_and_page_options/metadata.rb
@@ -12,12 +12,12 @@
:Author => "John Doe",
:Subject => "My Subject",
:Keywords => "test metadata ruby pdf dry",
- :Creator => "ACME Soft App",
+ :Creator => "ACME Soft App",
:Producer => "Prawn",
:CreationDate => Time.now,
:Grok => "Test Property"
}) do
-
+
text "This is a test of setting metadata properties via the info option."
text "It allows one to specify non standard properties like 'Grok'."
end
diff --git a/manual/document_and_page_options/page_margins.rb b/manual/document_and_page_options/page_margins.rb
index fe62940f7..7ce473ab2 100644
--- a/manual/document_and_page_options/page_margins.rb
+++ b/manual/document_and_page_options/page_margins.rb
@@ -20,7 +20,7 @@
start_new_page(:left_margin => 300)
text "300 pts margin on the left."
stroke_bounds
-
+
start_new_page(:top_margin => 300)
text "300 pts margin both on the top and on the left. Notice that whenever " +
"you set an option for a new page it will remain the default for the " +
@@ -28,10 +28,10 @@
stroke_bounds
start_new_page(:margin => 50)
- text "50 pts margins. Using the margin option will reset previous specific " +
+ text "50 pts margins. Using the margin option will reset previous specific " +
"calls to left, right, top and bottom margins."
stroke_bounds
-
+
start_new_page(:margin => [50, 100, 150, 200])
text "There is also the shorthand CSS like syntax used here."
stroke_bounds
diff --git a/manual/document_and_page_options/page_size.rb b/manual/document_and_page_options/page_size.rb
index a7196fda8..933e33f43 100644
--- a/manual/document_and_page_options/page_size.rb
+++ b/manual/document_and_page_options/page_size.rb
@@ -22,12 +22,12 @@
text "EXECUTIVE landscape page."
custom_size = [275, 326]
-
+
["A4", "TABLOID", "B7", custom_size ].each do |size|
-
+
start_new_page(:size => size, :layout => :portrait)
text "#{size} portrait page."
-
+
start_new_page(:size => size, :layout => :landscape)
text "#{size} landscape page."
end
diff --git a/manual/example_helper.rb b/manual/example_helper.rb
index 4c601c503..141d54754 100644
--- a/manual/example_helper.rb
+++ b/manual/example_helper.rb
@@ -14,7 +14,7 @@
Prawn.debug = true
module Prawn
-
+
# The Prawn::Example class holds all the helper methods used to generate the
# Prawn by example manual.
#
@@ -39,7 +39,7 @@ class Example < Prawn::Document
def load_package(package)
load_file(package, package)
end
-
+
# Loads a page with outline support. Used on the manual.
#
def load_page(page, page_name = nil)
@@ -57,7 +57,7 @@ def load_file(package, file)
data = read_file(package, "#{file}.rb")
eval extract_generate_block(data)
end
-
+
# Create a package cover and load the examples provided in examples_outline
# with outline support. Accepts an optional block to be used as the cover
# content. Used by the package files.
@@ -65,7 +65,7 @@ def load_file(package, file)
def build_package(package, examples_outline, &block)
title = package.gsub("_", " ").capitalize
header(title)
-
+
if block_given?
instance_eval(&block)
end
@@ -73,51 +73,51 @@ def build_package(package, examples_outline, &block)
outline.define do
section(title, :destination => page_number, :closed => true)
end
-
+
build_package_examples(package, title, examples_outline)
end
-
+
# Recursively iterates through the examples subsections or pages according
# to the examples_outline.
#
def build_package_examples(package, title, examples_outline)
examples_outline.each do |example_or_subsection|
-
+
case example_or_subsection
when Array
-
- outline.add_subsection_to(title) do
+
+ outline.add_subsection_to(title) do
outline.section(example_or_subsection.first, :closed => true)
end
-
+
build_package_examples(package,
example_or_subsection.first,
example_or_subsection.last)
-
+
when Hash
example = example_or_subsection.delete(:name)
load_example(package, "#{example}.rb", example_or_subsection)
-
- outline.add_subsection_to(title) do
+
+ outline.add_subsection_to(title) do
outline.page(:destination => page_number,
:title => example.gsub("_", " ").capitalize)
end
-
+
else
initial_page = page_number + 1
load_example(package, "#{example_or_subsection}.rb")
-
- outline.add_subsection_to(title) do
+
+ outline.add_subsection_to(title) do
outline.page(:destination => initial_page,
:title => example_or_subsection.gsub("_", " ").capitalize)
end
end
end
end
-
+
# Starts a new page to load an example from a given package. Renders an
# introductory text and the example source. Available boolean options are:
- #
+ #
# :eval_source:: Evals the example source code (default: true)
# :full_source:: Extract the full source code when true. Extract
# only the code between the generate block when false (default: false)
@@ -126,21 +126,21 @@ def load_example(package, example, options={})
options = { :eval_source => true,
:full_source => false
}.merge(options)
-
+
data = read_file(package, example)
-
+
if options[:full_source]
example_source = extract_full_source(data)
- else
+ else
example_source = extract_generate_block(data)
end
-
+
start_new_page
-
+
text(" tags
intro.gsub!(/([^<]+?)<\/code>/,
"\\1<\/font>")
-
+
# Process the links
intro.gsub!(/(https?:\/\/\S+)/,
"\\1")
-
+
intro
end
end
diff --git a/manual/graphics/circle_and_ellipse.rb b/manual/graphics/circle_and_ellipse.rb
index 6eada0618..2ec309ed9 100644
--- a/manual/graphics/circle_and_ellipse.rb
+++ b/manual/graphics/circle_and_ellipse.rb
@@ -12,10 +12,10 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
stroke_axis
-
+
stroke_circle [100, 300], 100
-
+
fill_ellipse [200, 100], 100, 50
-
+
fill_ellipse [400, 100], 50
end
diff --git a/manual/graphics/color.rb b/manual/graphics/color.rb
index b6bf70364..d5a832109 100644
--- a/manual/graphics/color.rb
+++ b/manual/graphics/color.rb
@@ -9,16 +9,16 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
stroke_axis
-
+
# Fill with Yellow
fill_color "FFFFCC" # RGB
fill_polygon [50, 150], [150, 200], [250, 150],
[250, 50], [150, 0], [50, 50]
-
+
# Stroke with Purple
stroke_color 50, 100, 0, 0 # CMYK
stroke_rectangle [300, 300], 200, 100
-
+
# Both together
fill_and_stroke_circle [400, 100], 50
@@ -27,6 +27,6 @@
bounding_box [10, 300], :width => 450, :height => 150 do
text "Gradient!", :size => 60
end
-
+
reset_drawing_settings
end
diff --git a/manual/graphics/common_lines.rb b/manual/graphics/common_lines.rb
index 468d7bceb..4fdf78039 100644
--- a/manual/graphics/common_lines.rb
+++ b/manual/graphics/common_lines.rb
@@ -15,14 +15,14 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
stroke_axis
-
+
stroke do
# just lower the current y position
- move_down 50
+ move_down 50
horizontal_rule
-
+
vertical_line 100, 300, :at => 50
-
+
horizontal_line 200, 500, :at => 150
end
end
diff --git a/manual/graphics/fill_and_stroke.rb b/manual/graphics/fill_and_stroke.rb
index b160a6128..9402bf708 100644
--- a/manual/graphics/fill_and_stroke.rb
+++ b/manual/graphics/fill_and_stroke.rb
@@ -23,18 +23,18 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
stroke_axis
-
+
# No block
line [0, 200], [100, 150]
stroke
-
+
rectangle [0, 100], 100, 100
fill
-
+
# With block
stroke { line [200, 200], [300, 150] }
fill { rectangle [200, 100], 100, 100 }
-
+
# Method hook
stroke_line [400, 200], [500, 150]
fill_rectangle [400, 100], 100, 100
diff --git a/manual/graphics/graphics.rb b/manual/graphics/graphics.rb
index 0d821140b..c2b48ec5b 100644
--- a/manual/graphics/graphics.rb
+++ b/manual/graphics/graphics.rb
@@ -33,14 +33,14 @@
]
]
]
-
+
) do
text "Here we show all the drawing methods provided by Prawn. Use them to draw the most beautiful imaginable things.
-
+
Most of the content that you'll add to your pdf document will use the graphics package. Even text is rendered on a page just like a rectangle is so even if you never use any of the shapes described here you should at least read the basic examples.
-
+
The examples show:"
-
+
list( "All the possible ways that you can fill or stroke shapes on a page",
"How to draw all the shapes that Prawn has to offer from a measly line to a mighty polygon or ellipse",
"What the configuration options are for stroking lines and filling shapes.",
diff --git a/manual/graphics/line_width.rb b/manual/graphics/line_width.rb
index 6f509ac91..2c583fccf 100644
--- a/manual/graphics/line_width.rb
+++ b/manual/graphics/line_width.rb
@@ -14,25 +14,25 @@
Prawn::Example.generate(filename) do
# Prawn::Document.generate() do
stroke_axis
-
+
y = 250
-
+
3.times do |i|
case i
when 0; line_width = 10 # This call will have no effect
when 1; self.line_width = 10
when 2; self.line_width = 25
end
-
+
stroke do
horizontal_line 50, 150, :at => y
rectangle [275, y + 25], 50, 50
circle [500, y], 25
end
-
+
y -= 100
end
-
+
# Return line_width back to normal
self.line_width = 1
end
diff --git a/manual/graphics/lines_and_curves.rb b/manual/graphics/lines_and_curves.rb
index 576e0884a..cc33d9c5e 100644
--- a/manual/graphics/lines_and_curves.rb
+++ b/manual/graphics/lines_and_curves.rb
@@ -20,18 +20,18 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
stroke_axis
-
+
# line_to and curve_to
stroke do
move_to 0, 0
-
+
line_to 100, 100
line_to 0, 100
-
+
curve_to [150, 250], :bounds => [[20, 200], [120, 200]]
curve_to [200, 0], :bounds => [[150, 200], [450, 10]]
end
-
+
# line and curve
stroke do
line [300,200], [400,50]
diff --git a/manual/graphics/polygon.rb b/manual/graphics/polygon.rb
index d48e431f6..c56cb2d61 100644
--- a/manual/graphics/polygon.rb
+++ b/manual/graphics/polygon.rb
@@ -15,14 +15,14 @@
# Triangle
stroke_polygon [50, 200], [50, 300], [150, 300]
-
+
# Hexagon
fill_polygon [50, 150], [150, 200], [250, 150],
[250, 50], [150, 0], [50, 50]
-
+
# Pentagram
pentagon_points = [500, 100], [430, 5], [319, 41], [319, 159], [430, 195]
pentagram_points = [0, 2, 4, 1, 3].map{|i| pentagon_points[i]}
-
+
stroke_rounded_polygon(20, *pentagram_points)
end
diff --git a/manual/graphics/rectangle.rb b/manual/graphics/rectangle.rb
index 3d57a3560..e1e4e3610 100644
--- a/manual/graphics/rectangle.rb
+++ b/manual/graphics/rectangle.rb
@@ -11,10 +11,10 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
stroke_axis
-
+
stroke do
rectangle [100, 300], 100, 200
-
+
rounded_rectangle [300, 300], 100, 200, 20
end
end
diff --git a/manual/graphics/rotate.rb b/manual/graphics/rotate.rb
index e1fed7f8e..738603c53 100644
--- a/manual/graphics/rotate.rb
+++ b/manual/graphics/rotate.rb
@@ -14,13 +14,13 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
stroke_axis
-
+
fill_circle [250, 200], 2
-
+
12.times do |i|
-
+
rotate(i * 30, :origin => [250, 200]) do
-
+
stroke_rectangle [350, 225], 100, 50
draw_text "Rotated #{i * 30}°", :size => 10, :at => [360, 205]
end
diff --git a/manual/graphics/scale.rb b/manual/graphics/scale.rb
index 0b25c0dca..1cd00535c 100644
--- a/manual/graphics/scale.rb
+++ b/manual/graphics/scale.rb
@@ -12,16 +12,16 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
stroke_axis
-
+
width = 100
height = 50
-
+
x = 50
y = 200
stroke_rectangle [x, y], width, height
text_box "reference rectangle", :at => [x + 10, y - 10], :width => width - 20
-
+
scale(2, :origin => [x, y]) do
stroke_rectangle [x, y], width, height
text_box "rectangle scaled from upper-left corner",
@@ -32,7 +32,7 @@
stroke_rectangle [x, y], width, height
text_box "reference rectangle", :at => [x + 10, y - 10], :width => width - 20
-
+
scale(2, :origin => [x + width / 2, y - height / 2]) do
stroke_rectangle [x, y], width, height
text_box "rectangle scaled from center",
diff --git a/manual/graphics/stroke_cap.rb b/manual/graphics/stroke_cap.rb
index bb70cdb8c..349e2d4f0 100644
--- a/manual/graphics/stroke_cap.rb
+++ b/manual/graphics/stroke_cap.rb
@@ -18,7 +18,7 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
stroke_axis
-
+
self.line_width = 25
y = 250
@@ -28,12 +28,12 @@
when 1; self.cap_style = :round
when 2; self.cap_style = :projecting_square
end
-
+
stroke_horizontal_line 100, 300, :at => y
stroke_circle [400, y], 15
-
+
y -= 100
end
-
+
reset_drawing_settings
end
diff --git a/manual/graphics/stroke_dash.rb b/manual/graphics/stroke_dash.rb
index 151e4813e..310c27292 100644
--- a/manual/graphics/stroke_dash.rb
+++ b/manual/graphics/stroke_dash.rb
@@ -8,7 +8,7 @@
# dashes.
#
# The :phase option defines the start point of the sequence of
-# dashes and spaces.
+# dashes and spaces.
#
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))
@@ -16,14 +16,14 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
stroke_axis
-
+
base_y = 210
-
+
24.times do |i|
length = (i / 4) + 1
space = length # space between dashes same length as dash
phase = 0 # start with dash
-
+
case i % 4
when 0
base_y -= 5
@@ -36,10 +36,10 @@
phase = length # start with space between dashes
end
base_y -= 5
-
+
dash(length, :space => space, :phase => phase)
stroke_horizontal_line 50, 500, :at => base_y - (2 * i)
end
-
+
undash # revert stroke back to normal
end
diff --git a/manual/graphics/stroke_join.rb b/manual/graphics/stroke_join.rb
index 77bb081d1..1d9ffd965 100644
--- a/manual/graphics/stroke_join.rb
+++ b/manual/graphics/stroke_join.rb
@@ -13,26 +13,26 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
stroke_axis
-
+
self.line_width = 25
y = 200
-
+
3.times do |i|
case i
when 0; self.join_style = :miter
when 1; self.join_style = :round
when 2; self.join_style = :bevel
end
-
+
stroke do
move_to(100, y)
line_to(200, y + 100)
line_to(300, y)
end
stroke_rectangle [400, y + 75], 50, 50
-
+
y -= 100
end
-
+
reset_drawing_settings
end
diff --git a/manual/graphics/translate.rb b/manual/graphics/translate.rb
index ac4f2514f..0f4e814f1 100644
--- a/manual/graphics/translate.rb
+++ b/manual/graphics/translate.rb
@@ -9,18 +9,18 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
stroke_axis
-
+
1.upto(3) do |i|
-
+
x = i * 50
y = i * 100
translate(x, y) do
-
+
# Draw a point on the new origin
fill_circle [0, 0], 2
draw_text "New origin after translation to [#{x}, #{y}]",
:at => [5, -2], :size => 8
-
+
stroke_rectangle [100, 75], 100, 50
text_box "Top left corner at [100,75]",
:at => [110, 65], :width => 80, :size => 8
diff --git a/manual/graphics/transparency.rb b/manual/graphics/transparency.rb
index 2d37ce219..0b69680a8 100644
--- a/manual/graphics/transparency.rb
+++ b/manual/graphics/transparency.rb
@@ -18,20 +18,20 @@
self.line_width = 5
fill_color "ff0000"
fill_rectangle [0, 100], 500, 100
-
+
fill_color "000000"
stroke_color "ffffff"
-
+
base_x = 100
[[0.5, 1], 0.5, [1, 0.5]].each do |args|
-
+
transparent(*args) do
fill_circle [base_x, 100], 50
stroke_rectangle [base_x - 20, 100], 40, 80
end
-
+
base_x += 150
end
-
+
reset_drawing_settings
end
diff --git a/manual/images/absolute_position.rb b/manual/images/absolute_position.rb
index 75f1dac1e..7575d4bb9 100644
--- a/manual/images/absolute_position.rb
+++ b/manual/images/absolute_position.rb
@@ -16,8 +16,8 @@
Prawn::Example.generate(filename) do
y_position = cursor
text "The image won't go below this line of text."
-
+
image "#{Prawn::DATADIR}/images/fractal.jpg", :at => [200, y_position]
-
+
text "And this line of text will go just below the previous one."
end
diff --git a/manual/images/fit.rb b/manual/images/fit.rb
index 11dc67be9..456f069e5 100644
--- a/manual/images/fit.rb
+++ b/manual/images/fit.rb
@@ -12,7 +12,7 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
size = 300
-
+
text "Using the fit option"
bounding_box([0, cursor], :width => size, :height => size) do
image "#{Prawn::DATADIR}/images/pigs.jpg", :fit => [size, size]
diff --git a/manual/images/horizontal.rb b/manual/images/horizontal.rb
index 120f95fa1..f53287bb1 100644
--- a/manual/images/horizontal.rb
+++ b/manual/images/horizontal.rb
@@ -13,12 +13,12 @@
Prawn::Example.generate(filename) do
bounding_box([50, cursor], :width => 400, :height => 450) do
stroke_bounds
-
+
[:left, :center, :right].each do |position|
text "Image aligned to the #{position}."
image "#{Prawn::DATADIR}/images/stef.jpg", :position => position
end
-
+
text "The next image has a 50 point offset from the left boundary"
image "#{Prawn::DATADIR}/images/stef.jpg", :position => 50
end
diff --git a/manual/images/scale.rb b/manual/images/scale.rb
index d0f23d9c5..4f0ee0c9b 100644
--- a/manual/images/scale.rb
+++ b/manual/images/scale.rb
@@ -13,11 +13,11 @@
text "Normal size"
image "#{Prawn::DATADIR}/images/stef.jpg"
move_down 10
-
+
text "Scaled to 50%"
image "#{Prawn::DATADIR}/images/stef.jpg", :scale => 0.5
move_down 10
-
+
text "Scaled to 200%"
image "#{Prawn::DATADIR}/images/stef.jpg", :scale => 2
end
diff --git a/manual/images/vertical.rb b/manual/images/vertical.rb
index 9f2b99977..d46c2aa06 100644
--- a/manual/images/vertical.rb
+++ b/manual/images/vertical.rb
@@ -12,13 +12,13 @@
Prawn::Example.generate(filename) do
bounding_box([0, cursor], :width => 500, :height => 450) do
stroke_bounds
-
+
[:top, :center, :bottom].each do |vposition|
text "Image vertically aligned to the #{vposition}.", :valign => vposition
image "#{Prawn::DATADIR}/images/stef.jpg", :position => 250,
:vposition => vposition
end
-
+
text_box "The next image has a 100 point offset from the top boundary",
:at => [bounds.width - 110, bounds.top - 10], :width => 100
image "#{Prawn::DATADIR}/images/stef.jpg", :position => :right,
diff --git a/manual/images/width_and_height.rb b/manual/images/width_and_height.rb
index 6304334a1..48e7c641d 100644
--- a/manual/images/width_and_height.rb
+++ b/manual/images/width_and_height.rb
@@ -15,11 +15,11 @@
text "Scale by setting only the width"
image "#{Prawn::DATADIR}/images/pigs.jpg", :width => 150
move_down 10
-
+
text "Scale by setting only the height"
image "#{Prawn::DATADIR}/images/pigs.jpg", :height => 100
move_down 10
-
+
text "Stretch to fit the width and height provided"
image "#{Prawn::DATADIR}/images/pigs.jpg", :width => 500, :height => 100
end
diff --git a/manual/layout/boxes.rb b/manual/layout/boxes.rb
index ba782a523..14e39e4b5 100644
--- a/manual/layout/boxes.rb
+++ b/manual/layout/boxes.rb
@@ -16,12 +16,12 @@
# The grid only need to be defined once, but since all the examples should be
# able to run alone we are repeating it on every example
define_grid(:columns => 5, :rows => 8, :gutter => 10)
-
+
grid(4,0).show
grid(5,1).show
-
+
grid([6,2], [7,3]).show
-
+
grid([4,4], [7,4]).show
grid([7,0], [7,1]).show
end
diff --git a/manual/layout/content.rb b/manual/layout/content.rb
index b1671c80e..c4f063cd0 100644
--- a/manual/layout/content.rb
+++ b/manual/layout/content.rb
@@ -14,11 +14,11 @@
# The grid only need to be defined once, but since all the examples should be
# able to run alone we are repeating it on every example
define_grid(:columns => 5, :rows => 8, :gutter => 10)
-
+
grid([5,0], [7,1]).bounding_box do
text "Adding some content to this multi_box.\n" + " _ " * 200
end
-
+
grid(6,3).bounding_box do
text "Just a little snippet here.\n" + " _ " * 10
end
diff --git a/manual/layout/simple_grid.rb b/manual/layout/simple_grid.rb
index 3e91e3ce4..8ac978a17 100644
--- a/manual/layout/simple_grid.rb
+++ b/manual/layout/simple_grid.rb
@@ -17,7 +17,7 @@
# able to run alone we are repeating it on every example
define_grid(:columns => 5, :rows => 8, :gutter => 10)
text "We defined the grid, roll over to the next page to see its outline"
-
+
start_new_page
grid.show_all
end
diff --git a/manual/manual/cover.rb b/manual/manual/cover.rb
index 5c0a4450c..e0dde83fd 100644
--- a/manual/manual/cover.rb
+++ b/manual/manual/cover.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
#
-# Prawn manual how to read this manual page.
+# Prawn manual how to read this manual page.
#
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))
@@ -12,7 +12,7 @@
image "#{Prawn::DATADIR}/images/prawn.png",
:scale => 0.9,
:at => [10, cursor]
-
+
formatted_text_box([ {:text => "Prawn\n",
:styles => [:bold],
:size => 100}
@@ -22,5 +22,5 @@
:font => 'Courier',
:size => 60}
], :at => [170, cursor - 160])
-
+
end
diff --git a/manual/manual/foreword.rb b/manual/manual/foreword.rb
index 7d2a900cb..c5f25bc4a 100644
--- a/manual/manual/foreword.rb
+++ b/manual/manual/foreword.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
#
-# Prawn manual foreword page.
+# Prawn manual foreword page.
#
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))
diff --git a/manual/manual/how_to_read.rb b/manual/manual/how_to_read.rb
index fa3c6117d..a1a1d338d 100644
--- a/manual/manual/how_to_read.rb
+++ b/manual/manual/how_to_read.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
#
-# Prawn manual how to read this manual page.
+# Prawn manual how to read this manual page.
#
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))
@@ -8,26 +8,26 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
header("How to read this manual")
-
+
text <<-END_TEXT
This manual is a collection of examples categorized by theme and organized from the least to the most complex. While it covers most of the common use cases it is not a comprehensive guide.
-
+
The best way to read it depends on your previous knowledge of Prawn and what you need to accomplish.
-
+
If you are beginning with Prawn the first chapter will teach you the most basic concepts and how to create pdf documents. For an overview of the other features each chapter beyond the first either has a Basics section (which offer enough insight on the feature without showing all the advanced stuff you might never use) or is simple enough with only a few examples.
-
+
Once you understand the basics you might want to come back to this manual looking for examples that accomplish tasks you need.
-
+
Advanced users are encouraged to go beyond this manual and read the source code directly if any doubt you have is not directly covered on this manual.
END_TEXT
-
+
header("Reading the examples")
-
+
text <<-END_TEXT
The title of each example is the relative path from the Prawn source manual/ folder.
-
+
The first body of text is the introductory text for the example. Generaly it is a short description of the feature or features illustrated by the example.
-
+
Next comes the example source code in fixed width font. Most of the example snippets illustrate features that alter the page in place. The effect of these snippets is shown right below a dashed line.
Note that the 'stroke_axis' method, used occasionally in the manual, is not part of standard Prawn and is used for demonstrative purposes. It is defined in manual/example_helper.rb.
diff --git a/manual/manual/manual.rb b/manual/manual/manual.rb
index 30e91ef6f..f5a878fc8 100644
--- a/manual/manual/manual.rb
+++ b/manual/manual/manual.rb
@@ -9,13 +9,13 @@
load_page "cover"
load_page "foreword"
load_page "how_to_read", "How to read this manual"
-
+
# Core chapters
load_package "basic_concepts"
load_package "graphics"
load_package "text"
load_package "bounding_box"
-
+
# Remaining chapters
load_package "layout"
load_package "table"
diff --git a/manual/outline/add_subsection_to.rb b/manual/outline/add_subsection_to.rb
index 2c728ed66..d2b621d9f 100644
--- a/manual/outline/add_subsection_to.rb
+++ b/manual/outline/add_subsection_to.rb
@@ -27,14 +27,14 @@
text "Page #{index}"
start_new_page
end
-
+
outline.define do
- section("Section 1", :destination => 1) do
+ section("Section 1", :destination => 1) do
page :title => "Page 2", :destination => 2
page :title => "Page 3", :destination => 3
end
end
-
+
# Now we will start adding nodes to the previous outline
outline.add_subsection_to("Section 1", :first) do
outline.section("Added later - first position") do
@@ -42,17 +42,17 @@
outline.page :title => "Page 5", :destination => 5
end
end
-
+
outline.add_subsection_to("Section 1") do
outline.page :title => "Added later - last position",
:destination => 6
end
-
+
outline.add_subsection_to("Added later - first position") do
outline.page :title => "Another page added later",
:destination => 7
end
-
+
# The title provided is for a page which will be converted into a section
outline.add_subsection_to("Page 3") do
outline.page :title => "Last page added",
diff --git a/manual/outline/insert_section_after.rb b/manual/outline/insert_section_after.rb
index 22a9e5e19..a2b7356f5 100644
--- a/manual/outline/insert_section_after.rb
+++ b/manual/outline/insert_section_after.rb
@@ -19,14 +19,14 @@
text "Page #{index}"
start_new_page
end
-
+
outline.define do
- section("Section 1", :destination => 1) do
+ section("Section 1", :destination => 1) do
page :title => "Page 2", :destination => 2
page :title => "Page 3", :destination => 3
end
end
-
+
# Now we will start adding nodes to the previous outline
outline.insert_section_after("Page 2") do
outline.section("Section after Page 2") do
@@ -39,7 +39,7 @@
outline.page :title => "Page 5", :destination => 5
end
end
-
+
# Adding just a page
outline.insert_section_after("Page 3") do
outline.page :title => "Page after Page 3", :destination => 6
diff --git a/manual/outline/outline.rb b/manual/outline/outline.rb
index d2ccfc763..fc8f2721a 100644
--- a/manual/outline/outline.rb
+++ b/manual/outline/outline.rb
@@ -19,7 +19,7 @@
]
]
]
-
+
) do
text "The outline of a PDF document is the table of contents tab you see to the right or left of your PDF viewer.
diff --git a/manual/outline/sections_and_pages.rb b/manual/outline/sections_and_pages.rb
index edd61550e..18b1dcb86 100644
--- a/manual/outline/sections_and_pages.rb
+++ b/manual/outline/sections_and_pages.rb
@@ -34,33 +34,33 @@
text "Page #{index}"
start_new_page
end
-
+
outline.define do
- section("Section 1", :destination => 1) do
+ section("Section 1", :destination => 1) do
page :title => "Page 2", :destination => 2
page :title => "Page 3", :destination => 3
end
-
+
section("Section 2", :destination => 4) do
page :title => "Page 5", :destination => 5
-
+
section("Subsection 2.1", :destination => 6, :closed => true) do
page :title => "Page 7", :destination => 7
end
end
end
-
+
# Outside of the define block
outline.section "Section 3", :destination => 8 do
outline.page :title => "Page 9", :destination => 9
end
-
+
outline.page :title => "Page 10", :destination => 10
-
+
# Section and Pages without links. While a section without a link may be
# useful to group some pages, a page without a link is useless
outline.update do # update is an alias to define
- section("Section without link") do
+ section("Section without link") do
page :title => "Page without link"
end
end
diff --git a/manual/repeatable_content/page_numbering.rb b/manual/repeatable_content/page_numbering.rb
index 1a9a1aeee..cbe1c7cf3 100644
--- a/manual/repeatable_content/page_numbering.rb
+++ b/manual/repeatable_content/page_numbering.rb
@@ -27,7 +27,7 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
text "This is the first page!"
-
+
10.times do
start_new_page
text "Here comes yet another page."
@@ -48,7 +48,7 @@
options[:start_count_at] = 8
options[:color] = "333333"
number_pages string, options
-
+
start_new_page
text "See. This page isn't numbered and doesn't count towards the total."
end
diff --git a/manual/repeatable_content/repeatable_content.rb b/manual/repeatable_content/repeatable_content.rb
index 2d6b17d63..c230b3afe 100644
--- a/manual/repeatable_content/repeatable_content.rb
+++ b/manual/repeatable_content/repeatable_content.rb
@@ -11,10 +11,10 @@
"stamp",
{:name => "page_numbering", :eval_source => false}
]
-
+
) do
text "Prawn offers two ways to handle repeatable content blocks. Repeater is useful for content that gets repeated at well defined intervals while Stamp is more appropriate if you need better control of when to repeat it.
-
+
There is also one very specific helper for numbering pages.
The examples show:"
diff --git a/manual/repeatable_content/repeater.rb b/manual/repeatable_content/repeater.rb
index 2c8450f58..c2b8fbf17 100644
--- a/manual/repeatable_content/repeater.rb
+++ b/manual/repeatable_content/repeater.rb
@@ -32,7 +32,7 @@
draw_text "Only even pages", :at => [0,0]
end
- repeat [1,3,7] do
+ repeat [1,3,7] do
draw_text "Only on pages 1, 3 and 7", :at => [100,0]
end
@@ -43,12 +43,12 @@
repeat(lambda { |pg| pg % 3 == 0 }) do
draw_text "Every third page", :at => [250, 20]
end
-
+
repeat(:all, :dynamic => true) do
draw_text page_number, :at => [500, 0]
end
- 10.times do
+ 10.times do
start_new_page
draw_text "A wonderful page", :at => [400,400]
end
diff --git a/manual/repeatable_content/stamp.rb b/manual/repeatable_content/stamp.rb
index 6a68ec565..9f045fb47 100644
--- a/manual/repeatable_content/stamp.rb
+++ b/manual/repeatable_content/stamp.rb
@@ -26,7 +26,7 @@
stroke_color "FF3333"
stroke_ellipse [0, 0], 29, 15
stroke_color "000000"
-
+
fill_color "993333"
font("Times-Roman") do
draw_text "Approved", :at => [-23, -3]
@@ -34,8 +34,8 @@
fill_color "000000"
end
end
-
+
stamp "approved"
-
+
stamp_at "approved", [200, 200]
end
diff --git a/manual/table/basic_block.rb b/manual/table/basic_block.rb
index f0fa8b4c8..d7e768f93 100644
--- a/manual/table/basic_block.rb
+++ b/manual/table/basic_block.rb
@@ -37,17 +37,17 @@
data = [ ["Header", "A " * 5, "B"],
["Data row", "C", "D " * 5],
["Another data row", "E", "F"]]
-
+
table(data) do
cells.padding = 12
cells.borders = []
-
+
row(0).borders = [:bottom]
row(0).border_width = 2
row(0).font_style = :bold
-
+
columns(0..1).borders = [:right]
-
+
row(0).columns(0..1).borders = [:bottom, :right]
end
end
diff --git a/manual/table/cell_borders_and_bg.rb b/manual/table/cell_borders_and_bg.rb
index dcd5efeba..e43004a86 100644
--- a/manual/table/cell_borders_and_bg.rb
+++ b/manual/table/cell_borders_and_bg.rb
@@ -16,16 +16,16 @@
data = [ ["Look at how the cells will look when styled", "", ""],
["They probably won't look the same", "", ""]
]
-
+
{ :borders => [:top, :left],
:border_width => 3,
:border_color => "FF0000"}.each do |property, value|
-
+
text "Cell #{property}: #{value.inspect}"
table(data, :cell_style => {property => value})
move_down 20
end
-
+
text "Cell background_color: FFFFCC"
table(data, :cell_style => {:background_color => "FFFFCC"})
end
diff --git a/manual/table/cell_dimensions.rb b/manual/table/cell_dimensions.rb
index 94f78d362..07d45ad33 100644
--- a/manual/table/cell_dimensions.rb
+++ b/manual/table/cell_dimensions.rb
@@ -18,13 +18,13 @@
data = [ ["Look at how the cells will look when styled", "", ""],
["They probably won't look the same", "", ""]
]
-
+
{:width => 160, :height => 50, :padding => 12}.each do |property, value|
text "Cell's #{property}: #{value}"
table(data, :cell_style => {property => value})
move_down 20
end
-
+
text "Padding can also be set with an array: [0, 0, 0, 30]"
table(data, :cell_style => {:padding => [0, 0, 0, 30]})
end
diff --git a/manual/table/cell_text.rb b/manual/table/cell_text.rb
index a7c37f974..68ffdee57 100644
--- a/manual/table/cell_text.rb
+++ b/manual/table/cell_text.rb
@@ -18,21 +18,21 @@
data = [ ["Look at how the cells will look when styled", "", ""],
["They probably won't look the same", "", ""]
]
-
+
table data, :cell_style => { :font => "Times-Roman", :font_style => :italic }
move_down 20
-
+
table data, :cell_style => { :size => 18, :text_color => "346842" }
move_down 20
-
+
table [["Just some inline", "", ""],
["styles being applied here", "", ""]],
:cell_style => { :inline_format => true }
move_down 20
-
+
table [["1", "2", "3", "rotate"]], :cell_style => { :rotate => 30 }
move_down 20
-
+
table data, :cell_style => { :overflow => :shrink_to_fit, :min_font_size => 8,
:width => 60, :height => 30 }
end
diff --git a/manual/table/column_widths.rb b/manual/table/column_widths.rb
index 49e08a215..ad98371ca 100644
--- a/manual/table/column_widths.rb
+++ b/manual/table/column_widths.rb
@@ -16,15 +16,15 @@
data = [ ["this is not quite as long as the others",
"here we have a line that is long but with smaller words",
"this is so very looooooooooooooooooooooooooooooong"] ]
-
+
text "Prawn trying to guess the column widths"
table(data)
move_down 20
-
+
text "Manually setting all the column widths"
table(data, :column_widths => [100, 200, 240])
move_down 20
-
+
text "Setting only the last column width"
table(data, :column_widths => {2 => 240})
end
diff --git a/manual/table/content_and_subtables.rb b/manual/table/content_and_subtables.rb
index aa833a1d6..86dab74c6 100644
--- a/manual/table/content_and_subtables.rb
+++ b/manual/table/content_and_subtables.rb
@@ -20,15 +20,15 @@
Prawn::Example.generate(filename) do
cell_1 = make_cell(:content => "this row content comes directly ")
cell_2 = make_cell(:content => "from cell objects")
-
+
two_dimensional_array = [ ["..."],
["subtable from an array"],
["..."] ]
-
+
inner_table = make_table([ ["..."],
["subtable from another table"],
["..."] ])
-
+
table([ ["just a regular row", "", "", "blah blah blah"],
[cell_1, cell_2, "", ""],
["", "", two_dimensional_array, ""],
diff --git a/manual/table/creation.rb b/manual/table/creation.rb
index 8423f91dd..75a23c343 100644
--- a/manual/table/creation.rb
+++ b/manual/table/creation.rb
@@ -20,7 +20,7 @@
["this is the second row"] ])
t.draw
move_down 20
-
+
table([ ["short", "short", "loooooooooooooooooooong"],
["short", "loooooooooooooooooooong", "short"],
["loooooooooooooooooooong", "short", "short"] ])
diff --git a/manual/table/filtering.rb b/manual/table/filtering.rb
index 5ad91ea2f..3129d235b 100644
--- a/manual/table/filtering.rb
+++ b/manual/table/filtering.rb
@@ -3,7 +3,7 @@
# Another way to reduce the number of cells is to filter the table.
#
# filter is just like Enumerable#select. Pass is a
-# block and it will iterate through the cells returning a new
+# block and it will iterate through the cells returning a new
# Prawn::Table::Cells instance containing only those cells for
# which the block was not false.
#
@@ -17,20 +17,20 @@
["Fridge", 62, 30],
["Microwave", 71, 47]
]
-
+
table(data) do
values = cells.columns(1..-1).rows(1..-1)
-
+
bad_sales = values.filter do |cell|
cell.content.to_i < 40
end
-
+
bad_sales.background_color = "FFAAAA"
good_sales = values.filter do |cell|
cell.content.to_i > 70
end
-
+
good_sales.background_color = "AAFFAA"
end
end
diff --git a/manual/table/flow_and_header.rb b/manual/table/flow_and_header.rb
index 731dd6596..bd72f43e9 100644
--- a/manual/table/flow_and_header.rb
+++ b/manual/table/flow_and_header.rb
@@ -11,6 +11,6 @@
Prawn::Example.generate(filename) do
data = [["This row should be repeated on every new page"]]
data += [["..."]] * 30
-
+
table(data, :header => true)
end
diff --git a/manual/table/row_colors.rb b/manual/table/row_colors.rb
index 579c17cf0..fd2a6377a 100644
--- a/manual/table/row_colors.rb
+++ b/manual/table/row_colors.rb
@@ -13,8 +13,8 @@
Prawn::Example.generate(filename) do
data = [["This row should have one color"],
["And this row should have another"]]
-
+
data += [["..."]] * 10
-
+
table(data, :row_colors => ["F0F0F0", "FFFFCC"])
end
diff --git a/manual/table/style.rb b/manual/table/style.rb
index a09c9b6fd..ab7040f1d 100644
--- a/manual/table/style.rb
+++ b/manual/table/style.rb
@@ -14,8 +14,8 @@
Prawn::Example.generate(filename) do
table [[""] * 8] * 8 do
cells.style(:width => 24, :height => 24)
-
- cells.style do |c|
+
+ cells.style do |c|
c.background_color = ((c.row + c.column) % 2).zero? ? '000000' : 'ffffff'
end
end
diff --git a/manual/table/width.rb b/manual/table/width.rb
index cddf89922..6e8d854f2 100644
--- a/manual/table/width.rb
+++ b/manual/table/width.rb
@@ -13,7 +13,7 @@
text "Normal width:"
table [%w[A B C]]
move_down 20
-
+
text "Fixed width:"
table([%w[A B C]], :width => 300)
move_down 20
@@ -21,7 +21,7 @@
text "Normal width:"
table([["A", "Blah " * 20, "C"]])
move_down 20
-
+
text "Fixed width:"
table([["A", "Blah " * 20, "C"]], :width => 300)
end
diff --git a/manual/templates/full_template.rb b/manual/templates/full_template.rb
index 2f1c4b55f..00fe5d111 100644
--- a/manual/templates/full_template.rb
+++ b/manual/templates/full_template.rb
@@ -15,9 +15,9 @@
Prawn::Example.generate("full_template.pdf", :template => filename) do
go_to_page(page_count)
-
+
start_new_page
-
+
text "Previous pages and content imported.", :align => :center
text "This page and content is brand new.", :align => :center
end
diff --git a/manual/templates/page_template.rb b/manual/templates/page_template.rb
index b53f62452..014d4292e 100644
--- a/manual/templates/page_template.rb
+++ b/manual/templates/page_template.rb
@@ -21,20 +21,20 @@
text "You also might want to look at the pdf used as a template: "
url = "https://github.com/sandal/prawn/raw/master/data/pdfs/form.pdf"
formatted_text [{:text => url, :link => url}]
-
+
filename = "#{Prawn::DATADIR}/pdfs/form.pdf"
start_new_page(:template => filename)
-
+
start_new_page(:template => filename, :template_page => 2)
-
+
start_new_page(:template => filename, :template_page => 2)
-
+
fill_color "FF8888"
-
+
text_box "John Doe", :at => [75, cursor-75]
text_box "john@doe.com", :at => [75, cursor-105]
text_box "John Doe inc", :at => [75, cursor-135]
text_box "You didn't think I'd tell, did you?", :at => [75, cursor-165]
-
+
fill_color "000000"
end
diff --git a/manual/templates/templates.rb b/manual/templates/templates.rb
index 6912e0bb4..81b1f08ea 100644
--- a/manual/templates/templates.rb
+++ b/manual/templates/templates.rb
@@ -13,7 +13,7 @@
},
"page_template"
]
-
+
) do
text "Templates let you embed other PDF documents inside the current one.
diff --git a/manual/text/font.rb b/manual/text/font.rb
index fc6d46298..1148b1062 100644
--- a/manual/text/font.rb
+++ b/manual/text/font.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-#
+#
# The font method can be used in three different ways.
#
# If we don't pass it any arguments it will return the current font being used
@@ -17,21 +17,21 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
text "Let's see which font we are using: #{font.inspect}"
-
+
move_down 20
font "Times-Roman"
text "Written in Times."
-
+
move_down 20
font("Courier") do
text "Written in Courier because we are inside the block."
end
-
+
move_down 20
text "Written in Times again as we left the previous block."
-
+
move_down 20
text "Let's see which font we are using again: #{font.inspect}"
-
+
font "Helvetica" # back to normal
end
diff --git a/manual/text/font_size.rb b/manual/text/font_size.rb
index 330725e12..8587d4e71 100644
--- a/manual/text/font_size.rb
+++ b/manual/text/font_size.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-#
+#
# The font_size method works just like the font method.
#
# In fact we can even use font with the :size option
@@ -14,27 +14,27 @@
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
text "Let's see which is the current font_size: #{font_size.inspect}"
-
+
move_down 10
font_size 16
text "Yeah, something bigger!"
-
+
move_down 10
font_size(25) { text "Even bigger!" }
-
+
move_down 10
text "Back to 16 again."
-
+
move_down 10
text "Single line on 20 using the :size option.", :size => 20
-
+
move_down 10
text "Back to 16 once more."
-
+
move_down 10
font("Courier", :size => 10) do
text "Yeah, using Courier 10 courtesy of the font method."
end
-
+
font("Helvetica", :size => 12) # back to normal
end
diff --git a/manual/text/font_style.rb b/manual/text/font_style.rb
index 1e189ee78..fd13873fd 100644
--- a/manual/text/font_style.rb
+++ b/manual/text/font_style.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-#
+#
# Most font families come with some styles other than normal. Most common are
# bold, italic and bold_italic.
#
@@ -13,16 +13,16 @@
Prawn::Example.generate(filename) do
["Courier", "Helvetica", "Times-Roman"].each do |example_font|
move_down 20
-
+
[:bold, :bold_italic, :italic, :normal].each do |style|
font example_font, :style => style
text "I'm writing in #{example_font} (#{style})"
end
end
-
+
move_down 20
font "Helvetica"
-
+
text "Normal"
text "Bold", :style => :bold
text "Bold Italic", :style => :bold_italic
diff --git a/manual/text/formatted_callbacks.rb b/manual/text/formatted_callbacks.rb
index c691b7ee7..773cc5267 100644
--- a/manual/text/formatted_callbacks.rb
+++ b/manual/text/formatted_callbacks.rb
@@ -40,7 +40,7 @@ def initialize(options)
def render_in_front(fragment)
@document.stroke_polygon(fragment.top_left, fragment.top_right,
fragment.bottom_right, fragment.bottom_left)
-
+
@document.fill_circle(fragment.top_left, @radius)
@document.fill_circle(fragment.top_right, @radius)
@document.fill_circle(fragment.bottom_right, @radius)
@@ -50,7 +50,7 @@ def render_in_front(fragment)
highlight = HighlightCallback.new(:color => 'ffff00', :document => self)
border = ConnectedBorderCallback.new(:radius => 2.5, :document => self)
-
+
formatted_text [ { :text => "hello", :callback => highlight },
{ :text => " " },
{ :text => "world", :callback => border },
diff --git a/manual/text/formatted_text.rb b/manual/text/formatted_text.rb
index 177a9fb36..ef1bdb326 100644
--- a/manual/text/formatted_text.rb
+++ b/manual/text/formatted_text.rb
@@ -39,7 +39,7 @@
:color => "0000FF",
:anchor => "Text Reference" }
]
-
+
formatted_text_box [ { :text => "Just your regular" },
{ :text => " text_box ", :font => "Courier" },
{ :text => "with some additional formatting options " +
diff --git a/manual/text/free_flowing_text.rb b/manual/text/free_flowing_text.rb
index ad35a96ce..bd49732bd 100644
--- a/manual/text/free_flowing_text.rb
+++ b/manual/text/free_flowing_text.rb
@@ -20,26 +20,26 @@
Prawn::Example.generate(filename) do
move_cursor_to 50
text "This text will flow to the next page. " * 20
-
+
y_position = cursor - 50
bounding_box [0, y_position], :width => 200, :height => 150 do
transparent(0.5) { stroke_bounds }
text "This text will flow along this bounding box we created for it. " * 5
end
-
+
bounding_box [300, y_position], :width => 200, :height => 150 do
transparent(0.5) { stroke_bounds } # This will stroke on one page
-
+
text "Now look what happens when the free flowing text reaches the end " +
"of a bounding box that is narrower than the margin box." +
" . " * 200 +
"It continues on the next page as if the previous bounding box " +
"was cloned. If we want it to have the same border as the one on " +
"the previous page we will need to stroke the boundaries again."
-
+
transparent(0.5) { stroke_bounds } # And this will stroke on the next
end
-
+
move_down 200
span(350, :position => :center) do
text "Span is a different kind of bounding box as it lets the text " +
diff --git a/manual/text/group.rb b/manual/text/group.rb
index 31c3f3c5e..343f41093 100644
--- a/manual/text/group.rb
+++ b/manual/text/group.rb
@@ -19,7 +19,7 @@
Prawn::Example.generate(filename) do
move_cursor_to 80
text "Let's move to the end of the page so that you can see group in action."
-
+
group do
text "This block of text was too big to be rendered on the bottom of the " +
" previous page. So it was rendered entirely on this new page. " +
diff --git a/manual/text/inline.rb b/manual/text/inline.rb
index a262bfdd8..55074ea32 100644
--- a/manual/text/inline.rb
+++ b/manual/text/inline.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-#
+#
# Inline formatting gives you the option to format specific portions of a text.
# It uses HTML-esque syntax inside the text string. Supported tags are:
# b (bold), i (italic), u (underline),
@@ -23,18 +23,18 @@
:inline_format => true
move_down 10
end
-
+
text "This line uses " +
"all the font tag attributes in " +
"a single line. ",
:inline_format => true
move_down 10
-
+
text "Coloring in both RGB " +
"and CMYK ",
:inline_format => true
move_down 10
-
+
text "This an external link to the " +
"Prawn wiki" +
" and this is a link to the " +
diff --git a/manual/text/kerning_and_character_spacing.rb b/manual/text/kerning_and_character_spacing.rb
index df682eeca..228a5243f 100644
--- a/manual/text/kerning_and_character_spacing.rb
+++ b/manual/text/kerning_and_character_spacing.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-#
+#
# Kerning is the process of adjusting the spacing between characters in a
# proportional font. It is usually done with specific letter pairs. We can
# switch it on and off if it is available with the current font. Just pass a
@@ -17,19 +17,19 @@
font_size(30) do
text_box "With kerning:", :kerning => true, :at => [0, y - 40]
text_box "Without kerning:", :kerning => false, :at => [0, y - 80]
-
+
text_box "Tomato", :kerning => true, :at => [250, y - 40]
text_box "Tomato", :kerning => false, :at => [250, y - 80]
-
+
text_box "WAR", :kerning => true, :at => [400, y - 40]
text_box "WAR", :kerning => false, :at => [400, y - 80]
-
+
text_box "F.", :kerning => true, :at => [500, y - 40]
text_box "F.", :kerning => false, :at => [500, y - 80]
end
-
+
move_down 80
-
+
string = "What have you done to the space between the characters?"
[-2, -1, 0, 0.5, 1, 2].each do |spacing|
move_down 20
diff --git a/manual/text/leading.rb b/manual/text/leading.rb
index 51f125461..2098851cb 100644
--- a/manual/text/leading.rb
+++ b/manual/text/leading.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-#
+#
# Leading is the additional space between lines of text.
#
# The leading can be set using the default_leading method which
@@ -13,13 +13,13 @@
Prawn::Example.generate(filename) do
string = "Hey, what did you do with the space between my lines? " * 10
text string, :leading => 0
-
+
move_down 20
default_leading 5
text string
-
+
move_down 20
text string, :leading => 10
-
+
default_leading 0 # back to normal
end
diff --git a/manual/text/line_wrapping.rb b/manual/text/line_wrapping.rb
index 553b9b38e..b584cef27 100644
--- a/manual/text/line_wrapping.rb
+++ b/manual/text/line_wrapping.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-#
+#
# Line wrapping happens on white space or hyphens. Soft hyphens can be used to
# indicate where words can be hyphenated. Non-breaking spaces can be used to
# display space without allowing for a break.
@@ -22,7 +22,7 @@
"Slip slid#{shy}ing away, slip slid#{shy}ing away. You know the " +
"nearer your destinat#{shy}ion the more you're slip slid#{shy}ing away."
move_down 20
-
+
nbsp = Prawn::Text::NBSP
text "Non-breaking spaces:\n" +
"Slip#{nbsp}sliding away, slip#{nbsp}sliding awaaaay. You know the " +
@@ -33,7 +33,7 @@
long_text = "No word boundaries:\n更可怕的是,同质化竞争对手可以按照URL中后面这个ID来遍历您的DB中的内容,写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事,这样的话,你就非常被动了。更可怕的是,同质化竞争对手可以按照URL中后面这个ID来遍历您的DB中的内容,写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事,这样的话,你就非常被动了。"
text long_text
move_down 20
-
+
zwsp = Prawn::Text::ZWSP
long_text = "Invisible word boundaries:\n更#{zwsp}可怕的#{zwsp}是,#{zwsp}同质化#{zwsp}竞争#{zwsp}对#{zwsp}手#{zwsp}可以#{zwsp}按照#{zwsp}URL#{zwsp}中#{zwsp}后面#{zwsp}这个#{zwsp}ID#{zwsp}来#{zwsp}遍历#{zwsp}您的#{zwsp}DB#{zwsp}中的#{zwsp}内容,#{zwsp}写个#{zwsp}小爬虫#{zwsp}把#{zwsp}你的#{zwsp}页面#{zwsp}上的#{zwsp}关#{zwsp}键#{zwsp}信#{zwsp}息顺#{zwsp}次#{zwsp}爬#{zwsp}下来#{zwsp}也#{zwsp}不是#{zwsp}什么#{zwsp}难事,#{zwsp}这样的话,#{zwsp}你#{zwsp}就#{zwsp}非常#{zwsp}被动了。#{zwsp}更#{zwsp}可怕的#{zwsp}是,#{zwsp}同质化#{zwsp}竞争#{zwsp}对#{zwsp}手#{zwsp}可以#{zwsp}按照#{zwsp}URL#{zwsp}中#{zwsp}后面#{zwsp}这个#{zwsp}ID#{zwsp}来#{zwsp}遍历#{zwsp}您的#{zwsp}DB#{zwsp}中的#{zwsp}内容,#{zwsp}写个#{zwsp}小爬虫#{zwsp}把#{zwsp}你的#{zwsp}页面#{zwsp}上的#{zwsp}关#{zwsp}键#{zwsp}信#{zwsp}息顺#{zwsp}次#{zwsp}爬#{zwsp}下来#{zwsp}也#{zwsp}不是#{zwsp}什么#{zwsp}难事,#{zwsp}这样的话,#{zwsp}你#{zwsp}就#{zwsp}非常#{zwsp}被动了。"
text long_text
diff --git a/manual/text/paragraph_indentation.rb b/manual/text/paragraph_indentation.rb
index 8cb7d8ec2..774339126 100644
--- a/manual/text/paragraph_indentation.rb
+++ b/manual/text/paragraph_indentation.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-#
+#
# Prawn strips all whitespace from the beginning and the end of strings so there
# are two ways to indent paragraphs:
#
@@ -17,7 +17,7 @@
# Using non-breaking spaces
text " " * 10 + "This paragraph won't be indented. " * 10 +
"\n#{Prawn::Text::NBSP * 10}" + "This one will with NBSP. " * 10
-
+
move_down 20
text "This paragraph will be indented. " * 10 +
"\n" + "This one will too. " * 10,
diff --git a/manual/text/positioned_text.rb b/manual/text/positioned_text.rb
index 0323048b3..df6e12978 100644
--- a/manual/text/positioned_text.rb
+++ b/manual/text/positioned_text.rb
@@ -25,13 +25,13 @@
draw_text "This draw_text line is absolute positioned. However don't " +
"expect it to flow even if it hits the document border",
:at => [200, 300]
-
+
text_box "This is a text box, you can control where it will flow by " +
"specifying the :height and :width options",
:at => [100, 250],
:height => 100,
:width => 100
-
+
text_box "Another text box with no :width option passed, so it will " +
"flow to a new line whenever it reaches the right margin. ",
:at => [200, 100]
diff --git a/manual/text/registering_families.rb b/manual/text/registering_families.rb
index bf6d784a7..43da5892f 100644
--- a/manual/text/registering_families.rb
+++ b/manual/text/registering_families.rb
@@ -17,12 +17,12 @@
font_families.update("Chalkboard" => {
:normal => "#{Prawn::DATADIR}/fonts/Chalkboard.ttf"
})
-
+
font("Chalkboard") do
text "Using the Chalkboard font providing only its name to the font method"
end
move_down 20
-
+
# Registering a DFONT package
font_path = "#{Prawn::DATADIR}/fonts/Action Man.dfont"
font_families.update("Action Man" => {
@@ -31,20 +31,20 @@
:bold => { :file => font_path, :font => "ActionMan-Bold" },
:bold_italic => { :file => font_path, :font => "ActionMan-BoldItalic" }
})
-
+
font "Action Man"
text "Also using the Action Man by providing only its name"
move_down 20
-
+
text "Taking advantage of the inline formatting",
:inline_format => true
move_down 20
-
+
[:bold, :bold_italic, :italic, :normal].each do |style|
text "Using the #{style} style option.",
:style => style
move_down 10
end
-
+
font "Helvetica" # Back to normal
end
diff --git a/manual/text/rendering_and_color.rb b/manual/text/rendering_and_color.rb
index 963d3c17b..e79ea7213 100644
--- a/manual/text/rendering_and_color.rb
+++ b/manual/text/rendering_and_color.rb
@@ -19,7 +19,7 @@
Prawn::Example.generate(filename) do
fill_color "00ff00"
stroke_color "0000ff"
-
+
font_size(40) do
# normal rendering mode: fill
text "This text is filled with green."
@@ -34,6 +34,6 @@
text "This text is filled with green and stroked with blue"
end
end
-
+
reset_drawing_settings
end
diff --git a/manual/text/right_to_left_text.rb b/manual/text/right_to_left_text.rb
index 236fcb1e9..806fae063 100644
--- a/manual/text/right_to_left_text.rb
+++ b/manual/text/right_to_left_text.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-#
+#
# Prawn can be used with right-to-left text. The direction can be set
# document-wide, on particular text, or on a text-box. Setting the direction to
# :rtl automatically changes the default alignment to :right
diff --git a/manual/text/rotation.rb b/manual/text/rotation.rb
index 302536cc2..afa7dca06 100644
--- a/manual/text/rotation.rb
+++ b/manual/text/rotation.rb
@@ -22,15 +22,15 @@
stroke_rectangle [0, y], width, height
text_box("This text was not rotated",
:at => [0, y], :width => width, :height => height)
-
+
stroke_rectangle [0, y - 100], width, height
text_box("This text was rotated around the center",
:at => [0, y - 100], :width => width, :height => height,
:rotate => angle, :rotate_around => :center)
-
+
[:lower_left, :upper_left,
:lower_right, :upper_right].each_with_index do |around, index|
-
+
y = y - 100 if index == 2
stroke_rectangle [x + (index % 2) * 200, y], width, height
text_box("This text was rotated around the #{around} corner.",
diff --git a/manual/text/single_usage.rb b/manual/text/single_usage.rb
index 772280297..9f38ea119 100644
--- a/manual/text/single_usage.rb
+++ b/manual/text/single_usage.rb
@@ -21,10 +21,10 @@
text "Written with the Chalkboard TTF font."
end
move_down 20
-
+
text "Written with the default font."
move_down 20
-
+
# Using an DFONT font file
font "#{Prawn::DATADIR}/fonts/Action Man.dfont" do
text "Written with the Action Man DFONT font"
diff --git a/manual/text/text.rb b/manual/text/text.rb
index 608566957..76171f714 100644
--- a/manual/text/text.rb
+++ b/manual/text/text.rb
@@ -45,7 +45,7 @@
]
]
]
-
+
) do
text "This is probably the feature people will use the most. There is no shortage of options when it comes to text. You'll be hard pressed to find a use case that is not covered by one of the text methods and confgurable options.
diff --git a/manual/text/text_box_excess.rb b/manual/text/text_box_excess.rb
index 56f3a0576..72190b44b 100644
--- a/manual/text/text_box_excess.rb
+++ b/manual/text/text_box_excess.rb
@@ -24,7 +24,7 @@
:overflow => :truncate,
:at => [100, y_position],
:size => 18
-
+
text_box excess_text,
:width => 300,
:at => [100, y_position - 50]
diff --git a/manual/text/text_box_extensions.rb b/manual/text/text_box_extensions.rb
index 71c5388e8..d9ff907b6 100644
--- a/manual/text/text_box_extensions.rb
+++ b/manual/text/text_box_extensions.rb
@@ -24,14 +24,14 @@ def available_width
y_position = cursor - 10
width = 100
height = 100
-
+
Prawn::Text::Box.extensions << TriangleBox
stroke_rectangle([0, y_position], width, height)
text_box("A" * 100,
:at => [0, y_position],
:width => width,
:height => height)
-
+
Prawn::Text::Formatted::Box.extensions << TriangleBox
stroke_rectangle([200, y_position], width, height)
formatted_text_box([:text => "A" * 100, :color => "009900"],
diff --git a/manual/text/text_box_overflow.rb b/manual/text/text_box_overflow.rb
index ae8ef503b..474bacd6f 100644
--- a/manual/text/text_box_overflow.rb
+++ b/manual/text/text_box_overflow.rb
@@ -21,17 +21,17 @@
"behave with the various overflow options used."
text string
-
+
y_position = cursor - 20
[:truncate, :expand, :shrink_to_fit].each_with_index do |mode, i|
text_box string, :at => [i * 150, y_position],
:width => 100, :height => 50,
:overflow => mode
end
-
+
string = "If the box is too small for the text, :shrink_to_fit " +
"can render the text in a really small font size."
-
+
move_down 120
text string
y_position = cursor - 20
diff --git a/manual/text/utf8.rb b/manual/text/utf8.rb
index 5ef234e41..df79ed674 100644
--- a/manual/text/utf8.rb
+++ b/manual/text/utf8.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-#
+#
# Multilingualization isn't much of a problem on Prawn as its default encoding
# is UTF-8. The only thing you need to worry about is if the font support the
# glyphs of your language.
@@ -12,15 +12,15 @@
text "Take this example, a simple Euro sign:"
text "€", :size => 32
move_down 20
-
+
text "Seems ok. Now let's try something more complex:"
text "ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει."
move_down 20
-
+
text "Looks like the current font (#{font.inspect}) doesn't support those."
text "Let's try them with another font."
move_down 20
-
+
font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf") do
text "ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει."
text "There you go."
diff --git a/spec/annotations_spec.rb b/spec/annotations_spec.rb
index 2943b1898..0496cd8ad 100644
--- a/spec/annotations_spec.rb
+++ b/spec/annotations_spec.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
-require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
-
+require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
+
class PageAnnotations
attr_reader :pages
@@ -20,11 +20,11 @@ def begin_page(params)
end
end
-describe "When creating annotations" do
-
+describe "When creating annotations" do
+
before(:each) { create_pdf }
-
- it "should append annotation to current page" do
+
+ it "should append annotation to current page" do
@pdf.start_new_page
@pdf.annotate(:Rect => [0,0,10,10], :Subtype => :Text, :Contents => "Hello world!")
obj = PageAnnotations.parse(@pdf)
@@ -42,14 +42,14 @@ def begin_page(params)
end
describe "When creating text annotations" do
-
+
before(:each) do
@rect = [0,0,10,10]
@content = "Hello, world!"
create_pdf
end
-
- it "should build appropriate annotation" do
+
+ it "should build appropriate annotation" do
opts = @pdf.text_annotation(@rect, @content)
opts[:Type].should == :Annot
opts[:Subtype].should == :Text
@@ -57,7 +57,7 @@ def begin_page(params)
opts[:Contents].should == @content
end
- it "should merge extra options" do
+ it "should merge extra options" do
opts = @pdf.text_annotation(@rect, @content, :Open => true, :Subtype => :Bogus)
opts[:Subtype].should == :Text
opts[:Open].should == true
@@ -66,14 +66,14 @@ def begin_page(params)
end
describe "When creating link annotations" do
-
+
before(:each) do
@rect = [0,0,10,10]
@dest = "home"
create_pdf
end
-
- it "should build appropriate annotation" do
+
+ it "should build appropriate annotation" do
opts = @pdf.link_annotation(@rect, :Dest => @dest)
opts[:Type].should == :Annot
opts[:Subtype].should == :Link
@@ -81,7 +81,7 @@ def begin_page(params)
opts[:Dest].should == @dest
end
- it "should merge extra options" do
+ it "should merge extra options" do
opts = @pdf.link_annotation(@rect, :Dest => @dest, :Subtype => :Bogus)
opts[:Subtype].should == :Link
opts[:Dest].should == @dest
diff --git a/spec/cell_spec.rb b/spec/cell_spec.rb
index 28e6b9e7c..d6cc7ffc0 100644
--- a/spec/cell_spec.rb
+++ b/spec/cell_spec.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
-require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
+require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
module CellHelpers
@@ -56,20 +56,20 @@ def close?(actual, expected, epsilon=0.01)
@pdf.expects(:move_down)
@pdf.expects(:draw_text!).with { |text, options| text == "hello world" }
- @pdf.cell(:content => "hello world",
+ @pdf.cell(:content => "hello world",
:at => [10, 20],
:padding => [30, 40],
- :size => 7,
+ :size => 7,
:font_style => :bold)
end
end
-
+
describe "Prawn::Document#make_cell" do
it "should not draw the cell" do
Prawn::Table::Cell::Text.any_instance.expects(:draw).never
@pdf.make_cell("text")
end
-
+
it "should return a Cell" do
@pdf.make_cell("text", :size => 7).should.be.a.kind_of Prawn::Table::Cell
end
@@ -117,7 +117,7 @@ def close?(actual, expected, epsilon=0.01)
it "should return proper width with size set" do
text = "text " * 4
c = cell(:content => text, :size => 7)
- c.width.should ==
+ c.width.should ==
@pdf.width_of(text, :size => 7) + c.padding[1] + c.padding[3]
end
@@ -164,7 +164,7 @@ def close?(actual, expected, epsilon=0.01)
it "should be calculated for text" do
c = cell(:content => "text")
- c.height.should ==
+ c.height.should ==
@pdf.height_of("text", :width => @pdf.width_of("text")) +
c.padding[0] + c.padding[3]
end
@@ -211,7 +211,7 @@ def close?(actual, expected, epsilon=0.01)
c = cell(:content => "text", :padding => 10)
c.content_height.should == @pdf.height_of("text")
end
-
+
it "content_height should exclude padding even with manual :height" do
c = cell(:content => "text", :padding => 10, :height => 400)
c.content_height.should.be.close(380, 0.01)
@@ -235,7 +235,7 @@ def close?(actual, expected, epsilon=0.01)
c = cell(:content => "text", :padding => [20, 30])
c.padding.should == [20, 30, 20, 30]
end
-
+
it "should accept [t,h,b]" do
c = cell(:content => "text", :padding => [10, 20, 30])
c.padding.should == [10, 20, 30, 20]
diff --git a/spec/destinations_spec.rb b/spec/destinations_spec.rb
index c31204d3e..b9205049e 100644
--- a/spec/destinations_spec.rb
+++ b/spec/destinations_spec.rb
@@ -1,12 +1,12 @@
# encoding: utf-8
-require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
+require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
+
+describe "When creating destinations" do
-describe "When creating destinations" do
-
before(:each) { create_pdf }
-
- it "should add entry to Dests name tree" do
+
+ it "should add entry to Dests name tree" do
@pdf.dests.data.empty?.should == true
@pdf.add_dest "candy", "chocolate"
@pdf.dests.data.size.should == 1
diff --git a/spec/document_spec.rb b/spec/document_spec.rb
index e1624cd80..232139a23 100644
--- a/spec/document_spec.rb
+++ b/spec/document_spec.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require "tempfile"
-require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
+require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
describe "Prawn::Document.new" do
it "should not modify its argument" do
@@ -15,9 +15,9 @@
it "should equal pdf.y - bounds.absolute_bottom" do
pdf = Prawn::Document.new
pdf.cursor.should == pdf.bounds.top
-
+
pdf.y = 300
- pdf.cursor.should == pdf.y - pdf.bounds.absolute_bottom
+ pdf.cursor.should == pdf.y - pdf.bounds.absolute_bottom
end
it "should be able to move relative to the bottom margin" do
@@ -27,12 +27,12 @@
pdf.cursor.should == 10
pdf.y.should == pdf.cursor + pdf.bounds.absolute_bottom
end
-end
+end
describe "when generating a document from a subclass" do
it "should be an instance of the subclass" do
custom_document = Class.new(Prawn::Document)
- custom_document.generate(Tempfile.new("generate_test").path) do |e|
+ custom_document.generate(Tempfile.new("generate_test").path) do |e|
e.class.should == custom_document
e.should.be.kind_of(Prawn::Document)
end
@@ -63,27 +63,27 @@
end
-
-describe "When creating multi-page documents" do
-
+
+describe "When creating multi-page documents" do
+
before(:each) { create_pdf }
-
- it "should initialize with a single page" do
+
+ it "should initialize with a single page" do
page_counter = PDF::Inspector::Page.analyze(@pdf.render)
-
- page_counter.pages.size.should == 1
- @pdf.page_count.should == 1
+
+ page_counter.pages.size.should == 1
+ @pdf.page_count.should == 1
end
-
+
it "should provide an accurate page_count" do
- 3.times { @pdf.start_new_page }
+ 3.times { @pdf.start_new_page }
page_counter = PDF::Inspector::Page.analyze(@pdf.render)
-
+
page_counter.pages.size.should == 4
@pdf.page_count.should == 4
- end
-
-end
+ end
+
+end
describe "When beginning each new page" do
@@ -102,11 +102,11 @@
@pdf.instance_variable_defined?(:@background).should == true
@pdf.instance_variable_get(:@background).should == @filename
end
-
-
+
+
end
-
-
+
+
end
describe "Prawn::Document#float" do
@@ -119,7 +119,7 @@
it "should teleport across pages if necessary" do
create_pdf
-
+
@pdf.float do
@pdf.text "Foo"
@pdf.start_new_page
@@ -156,7 +156,7 @@
describe "on_page_create callback" do
before do
- create_pdf
+ create_pdf
end
it "should be invoked with document" do
@@ -177,34 +177,34 @@
5.times { @pdf.start_new_page }
end
-
+
it "should be replaceable" do
trigger1 = mock()
trigger1.expects(:fire).times(1)
-
+
trigger2 = mock()
trigger2.expects(:fire).times(1)
@pdf.on_page_create { trigger1.fire }
-
+
@pdf.start_new_page
-
+
@pdf.on_page_create { trigger2.fire }
-
+
@pdf.start_new_page
end
-
+
it "should be clearable by calling on_page_create without a block" do
trigger = mock()
trigger.expects(:fire).times(1)
@pdf.on_page_create { trigger.fire }
- @pdf.start_new_page
-
+ @pdf.start_new_page
+
@pdf.on_page_create
-
- @pdf.start_new_page
+
+ @pdf.start_new_page
end
end
@@ -240,9 +240,9 @@
end
doc_compressed.render.length.should.be < doc_uncompressed.render.length
- end
+ end
-end
+end
describe "Document metadata" do
it "should output strings as UTF-16 with a byte order mark" do
@@ -262,7 +262,7 @@
pdf.go_to_page 1
pdf.text "More for page 1"
end
-
+
# MalformedPDFError raised if content stream actual length does not match
# dictionary length
lambda{ PDF::Inspector::Page.analyze(@pdf.render) }.
@@ -298,21 +298,21 @@
it "should default to LETTER" do
@pdf = Prawn::Document.new
pages = PDF::Inspector::Page.analyze(@pdf.render).pages
- pages.first[:size].should == Prawn::Document::PageGeometry::SIZES["LETTER"]
- end
-
+ pages.first[:size].should == Prawn::Document::PageGeometry::SIZES["LETTER"]
+ end
+
(Prawn::Document::PageGeometry::SIZES.keys - ["LETTER"]).each do |k|
it "should provide #{k} geometry" do
@pdf = Prawn::Document.new(:page_size => k)
- pages = PDF::Inspector::Page.analyze(@pdf.render).pages
+ pages = PDF::Inspector::Page.analyze(@pdf.render).pages
pages.first[:size].should == Prawn::Document::PageGeometry::SIZES[k]
end
end
-
- it "should allow custom page size" do
+
+ it "should allow custom page size" do
@pdf = Prawn::Document.new(:page_size => [1920, 1080] )
- pages = PDF::Inspector::Page.analyze(@pdf.render).pages
- pages.first[:size].should == [1920, 1080]
+ pages = PDF::Inspector::Page.analyze(@pdf.render).pages
+ pages.first[:size].should == [1920, 1080]
end
@@ -325,14 +325,14 @@
end
end
-end
+end
describe "When setting page layout" do
it "should reverse coordinates for landscape" do
@pdf = Prawn::Document.new(:page_size => "A4", :page_layout => :landscape)
- pages = PDF::Inspector::Page.analyze(@pdf.render).pages
+ pages = PDF::Inspector::Page.analyze(@pdf.render).pages
pages.first[:size].should == Prawn::Document::PageGeometry::SIZES["A4"].reverse
- end
+ end
it "should retain page layout by default when starting a new page" do
@pdf = Prawn::Document.new(:page_layout => :landscape)
@@ -362,7 +362,7 @@
@pdf.line_width.should.not == line_width
end
@pdf.y.should == y
- @pdf.line_width.should == line_width
+ @pdf.line_width.should == line_width
end
end
@@ -433,14 +433,14 @@
it "should trigger before_render callbacks just before rendering" do
pdf = Prawn::Document.new
-
+
seq = sequence("callback_order")
# Verify the order: finalize -> fire callbacks -> render body
pdf.expects(:finalize_all_page_contents).in_sequence(seq)
trigger = mock()
trigger.expects(:fire).in_sequence(seq)
-
+
# Store away the render_body method to be called below
render_body = pdf.method(:render_body)
pdf.expects(:render_body).in_sequence(seq)
@@ -464,10 +464,10 @@
describe "The :optimize_objects option" do
before(:all) do
@wasteful_doc = lambda do |pdf|
- pdf.transaction do
+ pdf.transaction do
pdf.start_new_page
pdf.text "Hidden text"
- pdf.rollback
+ pdf.rollback
end
pdf.text "Hello world"
@@ -483,7 +483,7 @@
it "should default to :false" do
default_pdf = Prawn::Document.new(&@wasteful_doc)
- wasteful_pdf = Prawn::Document.new(:optimize_objects => false,
+ wasteful_pdf = Prawn::Document.new(:optimize_objects => false,
&@wasteful_doc)
default_pdf.render.size.should == wasteful_pdf.render.size
end
@@ -565,25 +565,25 @@
before do
@pdf = Prawn::Document.new(:skip_page_creation => true)
end
-
+
it "replaces the '' string with the proper page number" do
@pdf.start_new_page
@pdf.expects(:text_box).with("1, test", { :height => 50 })
@pdf.number_pages ", test", {:page_filter => :all}
end
-
+
it "replaces the '' string with the total page count" do
@pdf.start_new_page
@pdf.expects(:text_box).with("test, 1", { :height => 50 })
@pdf.number_pages "test, ", {:page_filter => :all}
end
-
+
it "must print each page if given the :all page_filter" do
10.times { @pdf.start_new_page }
@pdf.expects(:text_box).times(10)
@pdf.number_pages "test", {:page_filter => :all}
end
-
+
it "must print each page if no :page_filter is specified" do
10.times { @pdf.start_new_page }
@pdf.expects(:text_box).times(10)
@@ -595,8 +595,8 @@
@pdf.expects(:text_box).never
@pdf.number_pages "test", {:page_filter => nil}
end
-
- context "start_count_at option" do
+
+ context "start_count_at option" do
[1, 2].each do |startat|
context "equal to #{startat}" do
it "increments the pages" do
@@ -605,10 +605,10 @@
@pdf.expects(:text_box).with("#{startat} 2", { :height => 50 })
@pdf.expects(:text_box).with("#{startat+1} 2", { :height => 50 })
@pdf.number_pages " ", options
- end
+ end
end
end
-
+
[0, nil].each do |val|
context "equal to #{val}" do
it "defaults to start at page 1" do
@@ -622,7 +622,7 @@
end
end
end
-
+
context "total_pages option" do
it "allows the total pages count to be overridden" do
2.times { @pdf.start_new_page }
@@ -631,7 +631,7 @@
@pdf.number_pages " ", :page_filter => :all, :total_pages => 10
end
end
-
+
context "special page filter" do
context "such as :odd" do
it "increments the pages" do
@@ -683,11 +683,11 @@
@pdf = Prawn::Document.new(:skip_page_creation => true)
10.times {@pdf.start_new_page}
end
-
+
it "returns nil given no filter" do
assert ! @pdf.page_match?(:nil, 1)
end
-
+
it "must provide an :all filter" do
assert (1..@pdf.page_count).all? { |i| @pdf.page_match?(:all, i) }
end
@@ -711,5 +711,5 @@
it "must be able to filter by an arbitrary proc" do
fltr = lambda { |x| x == 1 or x % 3 == 0 }
assert_equal [1,3,6,9], (1..10).select { |i| @pdf.page_match?(fltr, i) }
- end
+ end
end
diff --git a/spec/font_spec.rb b/spec/font_spec.rb
index 2efa142ac..ebc05244c 100644
--- a/spec/font_spec.rb
+++ b/spec/font_spec.rb
@@ -1,9 +1,9 @@
# encoding: utf-8
-require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
+require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
require 'iconv'
-describe "Font behavior" do
+describe "Font behavior" do
it "should default to Helvetica if no font is specified" do
@pdf = Prawn::Document.new
@@ -38,7 +38,7 @@
@pdf.font("Helvetica", :style => :bold) {
@bold_hello = @pdf.width_of("hello")
}
-
+
inline_bold_hello.should.be > normal_hello
inline_bold_hello.should == @bold_hello
end
@@ -65,33 +65,33 @@
describe "font style support" do
before(:each) { create_pdf }
-
+
it "should complain if there is no @current_page" do
pdf_without_page = Prawn::Document.new(:skip_page_creation => true)
lambda{ pdf_without_page.font "Helvetica" }.
should.raise(Prawn::Errors::NotOnPage)
end
-
- it "should allow specifying font style by style name and font family" do
+
+ it "should allow specifying font style by style name and font family" do
@pdf.font "Courier", :style => :bold
- @pdf.text "In Courier bold"
-
+ @pdf.text "In Courier bold"
+
@pdf.font "Courier", :style => :bold_italic
- @pdf.text "In Courier bold-italic"
-
+ @pdf.text "In Courier bold-italic"
+
@pdf.font "Courier", :style => :italic
- @pdf.text "In Courier italic"
-
+ @pdf.text "In Courier italic"
+
@pdf.font "Courier", :style => :normal
- @pdf.text "In Normal Courier"
-
+ @pdf.text "In Normal Courier"
+
@pdf.font "Helvetica"
- @pdf.text "In Normal Helvetica"
-
+ @pdf.text "In Normal Helvetica"
+
text = PDF::Inspector::Text.analyze(@pdf.render)
- text.font_settings.map { |e| e[:name] }.should ==
- [:"Courier-Bold", :"Courier-BoldOblique", :"Courier-Oblique",
+ text.font_settings.map { |e| e[:name] }.should ==
+ [:"Courier-Bold", :"Courier-BoldOblique", :"Courier-Oblique",
:Courier, :Helvetica]
end
@@ -116,20 +116,20 @@
describe "Transactional font handling" do
before(:each) { create_pdf }
-
+
it "should allow setting of size directly when font is created" do
@pdf.font "Courier", :size => 16
- @pdf.font_size.should == 16
+ @pdf.font_size.should == 16
end
-
+
it "should allow temporary setting of a new font using a transaction" do
@pdf.font "Helvetica", :size => 12
-
+
@pdf.font "Courier", :size => 16 do
@pdf.font.name.should == "Courier"
@pdf.font_size.should == 16
end
-
+
@pdf.font.name.should == "Helvetica"
@pdf.font_size.should == 12
end
@@ -144,57 +144,57 @@
@pdf.font_size.should == 12
end
-
+
end
describe "Document#page_fonts" do
- before(:each) { create_pdf }
-
+ before(:each) { create_pdf }
+
it "should register fonts properly by page" do
@pdf.font "Courier"; @pdf.text("hello")
@pdf.font "Helvetica"; @pdf.text("hello")
@pdf.font "Times-Roman"; @pdf.text("hello")
["Courier","Helvetica","Times-Roman"].each { |f|
page_should_include_font(f)
- }
-
- @pdf.start_new_page
+ }
+
+ @pdf.start_new_page
@pdf.font "Helvetica"; @pdf.text("hello")
page_should_include_font("Helvetica")
page_should_not_include_font("Courier")
page_should_not_include_font("Times-Roman")
- end
-
+ end
+
def page_includes_font?(font)
@pdf.page.fonts.values.map { |e| e.data[:BaseFont] }.include?(font.to_sym)
- end
-
- def page_should_include_font(font)
+ end
+
+ def page_should_include_font(font)
assert_block("Expected page to include font: #{font}") do
page_includes_font?(font)
end
- end
-
+ end
+
def page_should_not_include_font(font)
assert_block("Did not expect page to include font: #{font}") do
- not page_includes_font?(font)
+ not page_includes_font?(font)
end
end
-
+
end
-
+
describe "AFM fonts" do
-
+
setup do
create_pdf
@times = @pdf.find_font "Times-Roman"
@iconv = ::Iconv.new('Windows-1252', 'utf-8')
end
-
+
it "should calculate string width taking into account accented characters" do
@times.compute_width_of(@iconv.iconv("é"), :size => 12).should == @times.compute_width_of("e", :size => 12)
end
-
+
it "should calculate string width taking into account kerning pairs" do
@times.compute_width_of(@iconv.iconv("To"), :size => 12).should == 13.332
@times.compute_width_of(@iconv.iconv("To"), :size => 12, :kerning => true).should == 12.372
@@ -236,7 +236,7 @@ def page_should_not_include_font(font)
font_dict = zapf.send(:register, nil)
font_dict.data[:Encoding].should == nil
end
-
+
end
describe "#glyph_present" do
@@ -267,21 +267,21 @@ def page_should_not_include_font(font)
end
describe "TTF fonts" do
-
+
setup do
create_pdf
@activa = @pdf.find_font "#{Prawn::DATADIR}/fonts/Activa.ttf"
end
-
+
it "should calculate string width taking into account accented characters" do
@activa.compute_width_of("é", :size => 12).should == @activa.compute_width_of("e", :size => 12)
end
-
+
it "should calculate string width taking into account kerning pairs" do
@activa.compute_width_of("To", :size => 12).should == 15.228
@activa.compute_width_of("To", :size => 12, :kerning => true).should == 12.996
end
-
+
it "should encode text without kerning by default" do
@activa.encode_text("To").should == [[0, "To"]]
@@ -332,7 +332,7 @@ def page_should_not_include_font(font)
end
describe "when used with snapshots or transactions" do
-
+
it "should allow TTF fonts to be used alongside document transactions" do
lambda {
Prawn::Document.new do
@@ -358,7 +358,7 @@ def page_should_not_include_font(font)
end
end
-
+
end
describe "DFont fonts" do
diff --git a/spec/formatted_text_box_spec.rb b/spec/formatted_text_box_spec.rb
index 022a0a430..b1c6205c8 100644
--- a/spec/formatted_text_box_spec.rb
+++ b/spec/formatted_text_box_spec.rb
@@ -84,7 +84,7 @@
end
text_box.text.should == "Noua Delineatio Geographica\ngeneralis | Apostolicarum\nperegrinationum | S FRANCISCI\nXAUERII | Indiarum & Iaponi\346\nApostoli"
end
-
+
describe "Unicode" do
before do
if RUBY_VERSION < '1.9'
@@ -96,7 +96,7 @@
Encoding.default_internal = Encoding::UTF_8
end
end
-
+
after do
if RUBY_VERSION < '1.9'
$KCODE=@reset_value
diff --git a/spec/formatted_text_fragment_spec.rb b/spec/formatted_text_fragment_spec.rb
index a1c0dfac3..385cc8cf2 100644
--- a/spec/formatted_text_fragment_spec.rb
+++ b/spec/formatted_text_fragment_spec.rb
@@ -75,7 +75,7 @@
@fragment.ascender = 17
@fragment.word_spacing = 10
end
-
+
it "should account for word_spacing in #width" do
@fragment.width.should == 110
end
@@ -122,7 +122,7 @@
@fragment.descender = 7
@fragment.ascender = 17
end
-
+
describe "#width" do
it "should return the width" do
@fragment.width.should == 100
diff --git a/spec/graphics_spec.rb b/spec/graphics_spec.rb
index 6aeb83caf..a4dae93b4 100644
--- a/spec/graphics_spec.rb
+++ b/spec/graphics_spec.rb
@@ -121,7 +121,7 @@
curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)
curve.coords.should == [100.0, 100.0, 20.0, 90.0, 90.0, 75.0, 50.0, 50.0]
end
-
+
end
@@ -141,19 +141,19 @@
line_points.zip(curves).flatten.each_slice(2) {|p| @all_coords << p }
@all_coords.unshift @original_point
end
-
+
it "should draw a rectangle by connecting lines with rounded bezier curves" do
- @all_coords.should == [[60.0, 550.0],[90.0, 550.0], [95.523, 550.0], [100.0, 545.523], [100.0, 540.0],
- [100.0, 460.0], [100.0, 454.477], [95.523, 450.0], [90.0, 450.0],
- [60.0, 450.0], [54.477, 450.0], [50.0, 454.477], [50.0, 460.0],
+ @all_coords.should == [[60.0, 550.0],[90.0, 550.0], [95.523, 550.0], [100.0, 545.523], [100.0, 540.0],
+ [100.0, 460.0], [100.0, 454.477], [95.523, 450.0], [90.0, 450.0],
+ [60.0, 450.0], [54.477, 450.0], [50.0, 454.477], [50.0, 460.0],
[50.0, 540.0], [50.0, 545.523], [54.477, 550.0], [60.0, 550.0]]
end
-
+
it "should start and end with the same point" do
@original_point.should == @all_coords.last
end
-
-
+
+
end
describe "When drawing an ellipse" do
@@ -162,27 +162,27 @@
@pdf.ellipse [100,100], 25, 50
@curve = PDF::Inspector::Graphics::Curve.analyze(@pdf.render)
end
-
+
it "should use a Bézier approximation" do
- @curve.coords.should ==
+ @curve.coords.should ==
[125.0, 100.0,
125.0, 127.614,
113.807, 150,
100.0, 150.0,
-
+
86.193, 150.0,
75.0, 127.614,
75.0, 100.0,
-
+
75.0, 72.386,
86.193, 50.0,
100.0, 50.0,
-
+
113.807, 50.0,
125.0, 72.386,
125.0, 100.0,
-
+
100.0, 100.0]
end
@@ -268,7 +268,7 @@
colors.fill_color.should == [0.8,1.0,0.0]
colors.stroke_color.should == [1.0,0.0,0.8]
end
-
+
it "should set the color space when setting colors on new pages to please fussy readers" do
@pdf.stroke_color "000000"
@pdf.stroke { @pdf.rectangle([10, 10], 10, 10) }
@@ -339,80 +339,80 @@
describe "When using graphics states" do
before(:each) { create_pdf }
-
+
it "should add the right content on save_graphics_state" do
@pdf.expects(:add_content).with('q')
-
+
@pdf.save_graphics_state
end
-
+
it "should add the right content on restore_graphics_state" do
@pdf.expects(:add_content).with('Q')
-
+
@pdf.restore_graphics_state
end
-
+
it "should save and restore when save_graphics_state is used with a block" do
state = sequence "state"
@pdf.expects(:add_content).with('q').in_sequence(state)
@pdf.expects(:foo).in_sequence(state)
@pdf.expects(:add_content).with('Q').in_sequence(state)
-
+
@pdf.save_graphics_state do
@pdf.foo
end
end
-
+
it "should add the previous color space when restoring to a graphic state with different color space" do
@pdf.stroke_color '000000'
@pdf.save_graphics_state
@pdf.stroke_color 0, 0, 0, 0
- @pdf.restore_graphics_state
+ @pdf.restore_graphics_state
@pdf.stroke_color 0, 0, 100, 0
@pdf.graphic_state.color_space.should == {:stroke=>:DeviceCMYK}
colors = PDF::Inspector::Graphics::Color.analyze(@pdf.render)
colors.color_space.should == :DeviceCMYK
colors.stroke_color_space_count[:DeviceCMYK].should == 2
end
-
+
it "should use the correct dash setting after restoring and starting new page" do
@pdf.dash 5
@pdf.save_graphics_state
@pdf.dash 10
@pdf.graphic_state.dash[:dash].should == 10
- @pdf.restore_graphics_state
+ @pdf.restore_graphics_state
@pdf.start_new_page
@pdf.graphic_state.dash[:dash].should == 5
end
-
+
it "the current graphic state should keep track of previous unchanged settings" do
@pdf.stroke_color '000000'
@pdf.save_graphics_state
@pdf.dash 5
@pdf.save_graphics_state
@pdf.cap_style :round
- @pdf.save_graphics_state
+ @pdf.save_graphics_state
@pdf.fill_color 0, 0, 100, 0
@pdf.save_graphics_state
-
- @pdf.graphic_state.stroke_color.should == "000000"
+
+ @pdf.graphic_state.stroke_color.should == "000000"
@pdf.graphic_state.join_style.should == :miter
- @pdf.graphic_state.fill_color.should == [0, 0, 100, 0]
- @pdf.graphic_state.cap_style.should == :round
- @pdf.graphic_state.color_space.should == {:fill=>:DeviceCMYK, :stroke=>:DeviceRGB}
+ @pdf.graphic_state.fill_color.should == [0, 0, 100, 0]
+ @pdf.graphic_state.cap_style.should == :round
+ @pdf.graphic_state.color_space.should == {:fill=>:DeviceCMYK, :stroke=>:DeviceRGB}
@pdf.graphic_state.dash.should == {:space=>5, :phase=>0, :dash=>5}
@pdf.graphic_state.line_width.should == 1
end
-
-
-
+
+
+
it "should not add extra graphic space closings when rendering multiple times" do
@pdf.render
state = PDF::Inspector::Graphics::State.analyze(@pdf.render)
state.save_graphics_state_count.should == 1
state.restore_graphics_state_count.should == 1
end
-
+
it "should add extra graphic state enclosings when content is added on multiple renderings" do
@pdf.render
@pdf.text "Adding a bit more content"
@@ -420,7 +420,7 @@
state.save_graphics_state_count.should == 2
state.restore_graphics_state_count.should == 2
end
-
+
it "adds extra graphic state enclosings when new settings are applied on multiple renderings" do
@pdf.render
@pdf.stroke_color 0, 0, 0, 0
@@ -428,8 +428,8 @@
state.save_graphics_state_count.should == 2
state.restore_graphics_state_count.should == 2
end
-
-
+
+
it "should raise error if closing an empty graphic stack" do
assert_raise Prawn::Errors::EmptyGraphicStateStack do
@pdf.render
@@ -443,19 +443,19 @@
# Note: The (approximate) number of significant decimal digits of precision in fractional
# part is 5 (PDF Reference, Third Edition, p. 706)
-
+
it "should send the right content on transformation_matrix" do
@pdf.expects(:add_content).with('1.00000 0.00000 0.12346 -1.00000 5.50000 20.00000 cm')
@pdf.transformation_matrix 1, 0, 0.123456789, -1.0, 5.5, 20
end
-
+
it "should use fixed digits with very small number" do
values = Array.new(6, 0.000000000001)
string = Array.new(6, "0.00000").join " "
@pdf.expects(:add_content).with("#{string} cm")
@pdf.transformation_matrix *values
end
-
+
it "should be received by the inspector" do
@pdf.transformation_matrix 1, 0, 0, -1, 5.5, 20
matrices = PDF::Inspector::Graphics::Matrix.analyze(@pdf.render)
@@ -466,7 +466,7 @@
values = Array.new(6, 0.000000000001)
string = Array.new(6, "0.00000").join " "
process = sequence "process"
-
+
@pdf.expects(:save_graphics_state).with().in_sequence(process)
@pdf.expects(:add_content).with("#{string} cm").in_sequence(process)
@pdf.expects(:do_something).with().in_sequence(process)
@@ -475,7 +475,7 @@
@pdf.do_something
end
end
-
+
end
describe "When using transformations shortcuts" do
diff --git a/spec/grid_spec.rb b/spec/grid_spec.rb
index 64f6ab053..c5c849600 100644
--- a/spec/grid_spec.rb
+++ b/spec/grid_spec.rb
@@ -1,46 +1,46 @@
# encoding: utf-8
-require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
+require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
describe "A document's grid" do
before do
@pdf = Prawn::Document.new
end
-
+
it "should allow definition of a grid" do
@pdf.define_grid(:columns => 5, :rows => 8, :gutter => 0.1)
@pdf.grid.columns.should == 5
@pdf.grid.rows.should == 8
@pdf.grid.gutter.should == 0.1
end
-
+
describe "when a grid is defined" do
before do
@num_columns = 5
@num_rows = 8
@gutter = 10.0
@pdf.define_grid(
- :columns => @num_columns,
- :rows => @num_rows,
+ :columns => @num_columns,
+ :rows => @num_rows,
:gutter => @gutter
)
end
-
+
it "should compute the column width" do
- (@pdf.grid.column_width * @num_columns.to_f +
+ (@pdf.grid.column_width * @num_columns.to_f +
@gutter * (@num_columns - 1).to_f).should == @pdf.bounds.width
end
-
+
it "should compute the row height" do
- (@pdf.grid.row_height * @num_rows.to_f +
+ (@pdf.grid.row_height * @num_rows.to_f +
@gutter * (@num_rows - 1).to_f).should == @pdf.bounds.height
end
it "should give the edges of a grid box" do
- grid_width = (@pdf.bounds.width.to_f -
+ grid_width = (@pdf.bounds.width.to_f -
(@gutter * (@num_columns - 1).to_f )) / @num_columns.to_f
- grid_height = (@pdf.bounds.height.to_f -
+ grid_height = (@pdf.bounds.height.to_f -
(@gutter * (@num_rows - 1).to_f ))/ @num_rows.to_f
-
+
exp_tl_x = (grid_width + @gutter.to_f) * 4.0
exp_tl_y = @pdf.bounds.height.to_f - (grid_height + @gutter.to_f)
@@ -64,7 +64,7 @@
colors = PDF::Inspector::Graphics::Color.analyze(@pdf.render)
colors.fill_color.should.not == [0.8,0.8,0.8]
colors.stroke_color.should.not == [0.8,0.8,0.8]
-
+
# Hardcoded default color as I haven't been able to come up with a stable converter
# between fill_color without lots code.
#colors.fill_color.should == [0.0,0.0,0.0]
diff --git a/spec/images_spec.rb b/spec/images_spec.rb
index 825b908d7..8612dd525 100644
--- a/spec/images_spec.rb
+++ b/spec/images_spec.rb
@@ -1,40 +1,40 @@
# encoding: utf-8
-require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
+require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
require 'set'
require 'pathname'
describe "the image() function" do
before(:each) do
- @filename = "#{Prawn::DATADIR}/images/pigs.jpg"
+ @filename = "#{Prawn::DATADIR}/images/pigs.jpg"
create_pdf
end
it "should only embed an image once, even if it's added multiple times" do
@pdf.image @filename, :at => [100,100]
@pdf.image @filename, :at => [300,300]
-
+
output = @pdf.render
images = PDF::Inspector::XObject.analyze(output)
# there should be 2 images in the page resources
images.page_xobjects.first.size.should == 2
# but only 1 image xobject
output.scan(/\/Type \/XObject/).size.should == 1
- end
-
+ end
+
it "should return the image info object" do
info = @pdf.image(@filename)
-
+
info.should.be.kind_of(Prawn::Images::JPG)
-
+
info.height.should == 453
end
-
+
it "should accept IO objects" do
file = File.open(@filename, "rb")
info = @pdf.image(file)
-
+
info.height.should == 453
end
@@ -69,25 +69,25 @@
output.should =~ /\/BitsPerComponent 16/
output.should =~ /\/BitsPerComponent 8/
end
-
+
it "should flow an image to a new page if it will not fit on a page" do
@pdf.image @filename, :fit => [600, 600]
@pdf.image @filename, :fit => [600, 600]
output = StringIO.new(@pdf.render, 'r+')
hash = PDF::Reader::ObjectHash.new(output)
pages = hash.values.find {|obj| obj.is_a?(Hash) && obj[:Type] == :Pages}[:Kids]
- pages.size.should == 2
+ pages.size.should == 2
hash[pages[0]][:Resources][:XObject].keys.should == [:I1]
hash[pages[1]][:Resources][:XObject].keys.should == [:I2]
- end
-
+ end
+
it "should not flow an image to a new page if it will fit on one page" do
@pdf.image @filename, :fit => [400, 400]
@pdf.image @filename, :fit => [400, 400]
output = StringIO.new(@pdf.render, 'r+')
hash = PDF::Reader::ObjectHash.new(output)
pages = hash.values.find {|obj| obj.is_a?(Hash) && obj[:Type] == :Pages}[:Kids]
- pages.size.should == 1
+ pages.size.should == 1
Set.new(hash[pages[0]][:Resources][:XObject].keys).should ==
Set.new([:I1, :I2])
end
@@ -98,7 +98,7 @@
@pdf.image @filename
end
end
-
+
describe ":fit option" do
it "should fit inside the defined constraints" do
info = @pdf.image @filename, :fit => [100,400]
diff --git a/spec/jpg_spec.rb b/spec/jpg_spec.rb
index a36b55547..78f51837f 100644
--- a/spec/jpg_spec.rb
+++ b/spec/jpg_spec.rb
@@ -4,7 +4,7 @@
# contents of palette and transparency to ensure they're correct.
# Need to find files that have these sections first.
-require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
+require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
describe "When reading a JPEG file" do
@@ -12,10 +12,10 @@
@filename = "#{Prawn::DATADIR}/images/pigs.jpg"
@img_data = File.open(@filename, "rb") { |f| f.read }
end
-
+
it "should read the basic attributes correctly" do
jpg = Prawn::Images::JPG.new(@img_data)
-
+
jpg.width.should == 604
jpg.height.should == 453
jpg.bits.should == 8
diff --git a/spec/measurement_units_spec.rb b/spec/measurement_units_spec.rb
index d283e5084..24944b1e0 100644
--- a/spec/measurement_units_spec.rb
+++ b/spec/measurement_units_spec.rb
@@ -1,8 +1,8 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
+require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
require "prawn/measurement_extensions"
describe "Measurement units" do
-
+
it "should convert units to PostScriptPoints" do
1.mm.should.be.close(2.834645669, 0.000000001)
1.mm.should == (72 / 25.4)
@@ -12,12 +12,11 @@
1.cm.should == 10 * 72 / 25.4
1.dm.should == 100 * 72 / 25.4
1.m.should == 1000 * 72 / 25.4
-
+
1.in.should == 72
1.ft.should == 72 * 12
1.yd.should == 72 * 12 * 3
1.pt.should == 1
end
-
+
end
-
\ No newline at end of file
diff --git a/spec/name_tree_spec.rb b/spec/name_tree_spec.rb
index 74bab1b1f..9ede56ef3 100644
--- a/spec/name_tree_spec.rb
+++ b/spec/name_tree_spec.rb
@@ -24,7 +24,7 @@ def object_store
end
end
-describe "Name Tree" do
+describe "Name Tree" do
before(:each) { create_pdf(RefExposingDocument) }
it "should have no children when first initialized" do
@@ -50,7 +50,7 @@ def object_store
tree_add(node, ["one", 1], ["two", 2], ["three", 3], ["four", 4])
@pdf.object_store.length.should.equal ref_count+2
end
-
+
it "should create a one new reference when subtree is split" do
node = Prawn::Core::NameTree::Node.new(@pdf, 3)
tree_add(node, ["one", 1], ["two", 2], ["three", 3], ["four", 4])
diff --git a/spec/object_store_spec.rb b/spec/object_store_spec.rb
index b28f5211a..de43dd8a7 100644
--- a/spec/object_store_spec.rb
+++ b/spec/object_store_spec.rb
@@ -99,7 +99,7 @@
store.ref(:some => "structure")
old_size = store.size
store.compact
-
+
store.size.should.be < old_size
store.map{ |o| o.identifier }.should == (1..store.size).to_a
end
@@ -110,7 +110,7 @@
store.info.data[:Blah] = :overwritten
old_size = store.size
store.compact
-
+
store.size.should.be < old_size
store.map{ |o| o.identifier }.should == (1..store.size).to_a
end
diff --git a/spec/outline_spec.rb b/spec/outline_spec.rb
index 94c70838c..bc9403696 100644
--- a/spec/outline_spec.rb
+++ b/spec/outline_spec.rb
@@ -120,11 +120,11 @@
@outline_root[:Count].should == 5
end
- end
-
- describe "#outline.add_subsection_to" do
+ end
+
+ describe "#outline.add_subsection_to" do
context "positioned last" do
-
+
before(:each) do
@pdf.start_new_page
@pdf.text "Page 3. An added subsection "
@@ -133,45 +133,45 @@
section 'Added SubSection', :destination => 3 do
page :destination => 3, :title => 'Added Page 3'
end
- end
+ end
end
render_and_find_objects
end
-
+
it "should add new outline items to document" do
[@subsection, @added_page_3].each { |item| assert_not_nil item}
end
-
+
it "should reset the last item for parent item dictionary" do
referenced_object(@section_1[:First]).should == @page_1
referenced_object(@section_1[:Last]).should == @subsection
end
-
+
it "should set the prev relation for the new subsection to its parent's old last item" do
referenced_object(@subsection[:Prev]).should == @page_2
end
-
-
+
+
it "the subsection should become the next relation for its parent's old last item" do
referenced_object(@page_2[:Next]).should == @subsection
end
-
+
it "should set the first relation for the new subsection" do
referenced_object(@subsection[:First]).should == @added_page_3
end
-
+
it "should set the correct last relation of the added to section" do
referenced_object(@subsection[:Last]).should == @added_page_3
end
-
+
it "should increase the count of root outline dictionary" do
@outline_root[:Count].should == 5
end
-
- end
-
+
+ end
+
context "positioned first" do
-
+
before(:each) do
@pdf.start_new_page
@pdf.text "Page 3. An added subsection "
@@ -193,7 +193,7 @@
referenced_object(@section_1[:First]).should == @subsection
referenced_object(@section_1[:Last]).should == @page_2
end
-
+
it "should set the next relation for the new subsection to its parent's old first item" do
referenced_object(@subsection[:Next]).should == @page_1
end
@@ -215,7 +215,7 @@
end
end
-
+
it "should require an existing title" do
assert_raise Prawn::Errors::UnknownOutlineTitle do
@pdf.go_to_page 1
@@ -229,7 +229,7 @@
render_and_find_objects
end
end
- end
+ end
describe "#outline.insert_section_after" do
describe "inserting in the middle of another section" do
@@ -248,45 +248,45 @@
render_and_find_objects
assert_not_nil @inserted_page
end
-
+
it "should adjust the count of all ancestors" do
render_and_find_objects
@outline_root[:Count].should == 4
@section_1[:Count].should.abs == 3
end
-
+
describe "#adjust_relations" do
-
+
it "should reset the sibling relations of adjoining items to inserted item" do
render_and_find_objects
referenced_object(@page_1[:Next]).should == @inserted_page
referenced_object(@page_2[:Prev]).should == @inserted_page
end
-
+
it "should set the sibling relation of added item to adjoining items" do
render_and_find_objects
referenced_object(@inserted_page[:Next]).should == @page_2
referenced_object(@inserted_page[:Prev]).should == @page_1
end
-
+
it "should not affect the first and last relations of parent item" do
render_and_find_objects
referenced_object(@section_1[:First]).should == @page_1
referenced_object(@section_1[:Last]).should == @page_2
end
-
- end
-
-
- context "when adding another section afterwards" do
+
+ end
+
+
+ context "when adding another section afterwards" do
it "should have reset the root position so that a new section is added at the end of root sections" do
@pdf.start_new_page
@pdf.text "Another Inserted Page"
@pdf.outline.update do
section 'Added Section' do
page :destination => page_number, :title => "Inserted Page"
- end
- end
+ end
+ end
render_and_find_objects
referenced_object(@outline_root[:Last]).should == @section_2
referenced_object(@section_1[:Next]).should == @section_2
@@ -305,7 +305,7 @@
@pdf.outline.update do
insert_section_after 'Page 2' do
page :destination => page_number, :title => "Inserted Page"
- end
+ end
end
render_and_find_objects
end
@@ -357,7 +357,7 @@
end
end
end
-
+
context "foreign character encoding" do
before(:each) do
pdf = Prawn::Document.new() do
@@ -384,7 +384,7 @@ def render_and_find_objects
@page_2 = find_by_title('Page 2')
@section_2 = find_by_title('Added Section')
@page_3 = find_by_title('Page 3')
- @inserted_page = find_by_title('Inserted Page')
+ @inserted_page = find_by_title('Inserted Page')
@subsection = find_by_title('Added SubSection')
@added_page_3 = find_by_title('Added Page 3')
end
diff --git a/spec/pdf_object_spec.rb b/spec/pdf_object_spec.rb
index c015256c9..8d2d191b0 100644
--- a/spec/pdf_object_spec.rb
+++ b/spec/pdf_object_spec.rb
@@ -2,40 +2,40 @@
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
-# See PDF Reference, Sixth Edition (1.7) pp51-60 for details
-describe "PDF Object Serialization" do
-
+# See PDF Reference, Sixth Edition (1.7) pp51-60 for details
+describe "PDF Object Serialization" do
+
it "should convert Ruby's nil to PDF null" do
Prawn::Core::PdfObject(nil).should == "null"
end
-
+
it "should convert Ruby booleans to PDF booleans" do
Prawn::Core::PdfObject(true).should == "true"
Prawn::Core::PdfObject(false).should == "false"
end
-
+
it "should convert a Ruby number to PDF number" do
Prawn::Core::PdfObject(1).should == "1"
- Prawn::Core::PdfObject(1.214112421).should == "1.214112421"
+ Prawn::Core::PdfObject(1.214112421).should == "1.214112421"
# scientific notation is not valid in PDF
Prawn::Core::PdfObject(0.000005).should == "0.000005"
end
-
+
it "should convert a Ruby time object to a PDF timestamp" do
t = Time.now
Prawn::Core::PdfObject(t).should == t.strftime("(D:%Y%m%d%H%M%S%z").chop.chop + "'00')"
end
-
- it "should convert a Ruby string to PDF string when inside a content stream" do
+
+ it "should convert a Ruby string to PDF string when inside a content stream" do
s = "I can has a string"
PDF::Inspector.parse(Prawn::Core::PdfObject(s, true)).should == s
- end
+ end
- it "should convert a Ruby string to a UTF-16 PDF string when outside a content stream" do
+ it "should convert a Ruby string to a UTF-16 PDF string when outside a content stream" do
s = "I can has a string"
s_utf16 = "\xFE\xFF" + s.unpack("U*").pack("n*")
PDF::Inspector.parse(Prawn::Core::PdfObject(s, false)).should == s_utf16
- end
+ end
it "should convert a Ruby string with characters outside the BMP to its " +
"UTF-16 representation with a BOM" do
@@ -48,16 +48,16 @@
Prawn::Core::PdfObject(Prawn::Core::ByteString.new("\xDE\xAD\xBE\xEF")).upcase.
should == ""
end
-
+
it "should escape parens when converting from Ruby string to PDF" do
- s = 'I )(can has a string'
+ s = 'I )(can has a string'
PDF::Inspector.parse(Prawn::Core::PdfObject(s, true)).should == s
- end
-
+ end
+
it "should handle ruby escaped parens when converting to PDF string" do
s = 'I can \\)( has string'
- PDF::Inspector.parse(Prawn::Core::PdfObject(s, true)).should == s
- end
+ PDF::Inspector.parse(Prawn::Core::PdfObject(s, true)).should == s
+ end
it "should escape various strings correctly when converting a LiteralString" do
ls = Prawn::Core::LiteralString.new("abc")
@@ -100,7 +100,7 @@
Prawn::Core::PdfObject(:"A;Name_With-Various***Characters?").should ==
"/A;Name_With-Various***Characters?"
end
-
+
it "should convert a whitespace or delimiter containing Ruby symbol to a PDF name" do
Prawn::Core::PdfObject(:"my symbol").should == "/my#20symbol"
Prawn::Core::PdfObject(:"my#symbol").should == "/my#23symbol"
@@ -110,52 +110,52 @@
Prawn::Core::PdfObject(:"mysymbol").should == "/my#3Esymbol"
end
-
+
it "should convert a Ruby array to PDF Array when inside a content stream" do
Prawn::Core::PdfObject([1,2,3]).should == "[1 2 3]"
- PDF::Inspector.parse(Prawn::Core::PdfObject([[1,2],:foo,"Bar"], true)).should ==
+ PDF::Inspector.parse(Prawn::Core::PdfObject([[1,2],:foo,"Bar"], true)).should ==
[[1,2],:foo, "Bar"]
- end
+ end
it "should convert a Ruby array to PDF Array when outside a content stream" do
bar = "\xFE\xFF" + "Bar".unpack("U*").pack("n*")
Prawn::Core::PdfObject([1,2,3]).should == "[1 2 3]"
- PDF::Inspector.parse(Prawn::Core::PdfObject([[1,2],:foo,"Bar"], false)).should ==
+ PDF::Inspector.parse(Prawn::Core::PdfObject([[1,2],:foo,"Bar"], false)).should ==
[[1,2],:foo, bar]
- end
-
+ end
+
it "should convert a Ruby hash to a PDF Dictionary when inside a content stream" do
- dict = Prawn::Core::PdfObject( {:foo => :bar,
- "baz" => [1,2,3],
- :bang => {:a => "what", :b => [:you, :say] }}, true )
+ dict = Prawn::Core::PdfObject( {:foo => :bar,
+ "baz" => [1,2,3],
+ :bang => {:a => "what", :b => [:you, :say] }}, true )
- res = PDF::Inspector.parse(dict)
+ res = PDF::Inspector.parse(dict)
res[:foo].should == :bar
res[:baz].should == [1,2,3]
res[:bang].should == { :a => "what", :b => [:you, :say] }
- end
+ end
it "should convert a Ruby hash to a PDF Dictionary when outside a content stream" do
what = "\xFE\xFF" + "what".unpack("U*").pack("n*")
- dict = Prawn::Core::PdfObject( {:foo => :bar,
- "baz" => [1,2,3],
+ dict = Prawn::Core::PdfObject( {:foo => :bar,
+ "baz" => [1,2,3],
:bang => {:a => "what", :b => [:you, :say] }}, false )
- res = PDF::Inspector.parse(dict)
+ res = PDF::Inspector.parse(dict)
res[:foo].should == :bar
res[:baz].should == [1,2,3]
res[:bang].should == { :a => what, :b => [:you, :say] }
- end
-
+ end
+
it "should not allow keys other than strings or symbols for PDF dicts" do
lambda { Prawn::Core::PdfObject(:foo => :bar, :baz => :bang, 1 => 4) }.
- should.raise(Prawn::Errors::FailedObjectConversion)
- end
-
+ should.raise(Prawn::Errors::FailedObjectConversion)
+ end
+
it "should convert a Prawn::Reference to a PDF indirect object reference" do
ref = Prawn::Core::Reference(1,true)
Prawn::Core::PdfObject(ref).should == ref.to_s
diff --git a/spec/reference_spec.rb b/spec/reference_spec.rb
index fe40f7eab..f38b051df 100644
--- a/spec/reference_spec.rb
+++ b/spec/reference_spec.rb
@@ -6,22 +6,22 @@
it "should produce a PDF reference on #to_s call" do
ref = Prawn::Core::Reference(1,true)
ref.to_s.should == "1 0 R"
- end
-
+ end
+
it "should allow changing generation number" do
ref = Prawn::Core::Reference(1,true)
ref.gen = 1
ref.to_s.should == "1 1 R"
end
-
+
it "should generate a valid PDF object for the referenced data" do
- ref = Prawn::Core::Reference(2,[1,"foo"])
- ref.object.should == "2 0 obj\n#{Prawn::Core::PdfObject([1,"foo"])}\nendobj\n"
- end
-
+ ref = Prawn::Core::Reference(2,[1,"foo"])
+ ref.object.should == "2 0 obj\n#{Prawn::Core::PdfObject([1,"foo"])}\nendobj\n"
+ end
+
it "should automatically open a stream when #<< is used" do
ref = Prawn::Core::Reference(1, :Length => 41)
- ref << "BT\n/F1 12 Tf\n72 712 Td\n( A stream ) Tj\nET"
+ ref << "BT\n/F1 12 Tf\n72 712 Td\n( A stream ) Tj\nET"
ref.object.should == "1 0 obj\n<< /Length 41\n>>\nstream"+
"\nBT\n/F1 12 Tf\n72 712 Td\n( A stream ) Tj\nET" +
"\nendstream\nendobj\n"
@@ -35,7 +35,7 @@
cref << "Hi There " * 20
cref.compress_stream
- assert cref.stream.size < ref.stream.size,
+ assert cref.stream.size < ref.stream.size,
"compressed stream expected to be smaller than source but wasn't"
cref.data[:Filter].should == :FlateDecode
end
diff --git a/spec/repeater_spec.rb b/spec/repeater_spec.rb
index bfbed6b16..036521a69 100644
--- a/spec/repeater_spec.rb
+++ b/spec/repeater_spec.rb
@@ -150,7 +150,7 @@ def repeater(*args, &b)
text.strings.include?("cap_style: round").should == false
text.strings.include?("cap_style: butt").should == true
end
-
+
end
end
diff --git a/spec/security_spec.rb b/spec/security_spec.rb
index 12ac86bf8..2ebf286f5 100644
--- a/spec/security_spec.rb
+++ b/spec/security_spec.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
require "tempfile"
-require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
+require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
describe "Document encryption" do
@@ -31,9 +31,9 @@
end
end
-
+
describe "Setting permissions" do
-
+
def doc_with_permissions(permissions)
pdf = Prawn::Document.new
@@ -120,7 +120,7 @@ class << @pdf
Prawn::Core::EncryptedPdfObject(["foo", "bar"], "12345", 123, 0).should ==
"[<4ad6e3> <4ed8fe>]"
end
-
+
end
end
diff --git a/spec/snapshot_spec.rb b/spec/snapshot_spec.rb
index ed8bd9dce..a7c9fc945 100644
--- a/spec/snapshot_spec.rb
+++ b/spec/snapshot_spec.rb
@@ -23,7 +23,7 @@
end
text = PDF::Inspector::Text.analyze(pdf.render)
text.strings.should == []
- end
+ end
it "should return true/false value indicating success of the transaction" do
Prawn::Document.new do
@@ -34,7 +34,7 @@
success.should == false
end
end
-
+
it "should support nested transactions" do
pdf = Prawn::Document.new do
transaction do
@@ -144,7 +144,7 @@ def add_lines(pdf)
lambda { pdf.transaction{} }.should.not.raise
end
end
-
+
describe "with a stamp dictionary present" do
it "should properly commit if no error is raised" do
@@ -167,7 +167,7 @@ def add_lines(pdf)
end
end
pdf.render.should.not =~ /\/Stamp1 Do/
- end
+ end
end
diff --git a/spec/span_spec.rb b/spec/span_spec.rb
index c1dabaa06..d73eda651 100644
--- a/spec/span_spec.rb
+++ b/spec/span_spec.rb
@@ -2,8 +2,8 @@
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
-describe "drawing span" do
-
+describe "drawing span" do
+
def setup
Prawn.debug = false
create_pdf
@@ -28,9 +28,9 @@ def teardown
@pdf.span(350, :position => :center) do
@pdf.text "Here's some centered text in a 350 point column. " * 100
end
-
+
@pdf.bounds.should == margin_box
-
+
end
it "should do create a margin box" do
@@ -38,12 +38,12 @@ def teardown
margin_box = @pdf.span(350, :position => :center) do
@pdf.text "Here's some centered text in a 350 point column. " * 100
end
-
+
margin_box.top.should == 792.0
- margin_box.bottom.should == 0
-
- end
-
+ margin_box.bottom.should == 0
+
+ end
+
end
-
+
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 7fd215fcd..96e394a9c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -6,7 +6,7 @@
require "bundler"
Bundler.setup
-$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
+$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require "prawn"
Prawn.debug = true
@@ -18,7 +18,7 @@
def create_pdf(klass=Prawn::Document)
@pdf = klass.new(:margin => 0)
-end
+end
# Make some methods public to assist in testing
module Prawn::Graphics
diff --git a/spec/stamp_spec.rb b/spec/stamp_spec.rb
index ad245c7f8..cefc62482 100644
--- a/spec/stamp_spec.rb
+++ b/spec/stamp_spec.rb
@@ -41,7 +41,7 @@
@pdf.create_stamp("MyStamp")
}.should.raise(Prawn::Errors::NameTaken)
end
-
+
it "should raise InvalidName error when attempt to create "+
"stamp with a blank name" do
create_pdf
@@ -49,14 +49,14 @@
@pdf.create_stamp("")
}.should.raise(Prawn::Errors::InvalidName)
end
-
+
it "a new XObject should be defined for each stamp created" do
create_pdf
@pdf.create_stamp("MyStamp")
@pdf.create_stamp("AnotherStamp")
@pdf.stamp("MyStamp")
@pdf.stamp("AnotherStamp")
-
+
inspector = PDF::Inspector::XObject.analyze(@pdf.render)
xobjects = inspector.page_xobjects.last
xobjects.length.should == 2
@@ -105,7 +105,7 @@
end
end
end
-
+
it "stamp stream should be wrapped in a graphic state" do
create_pdf
@pdf.create_stamp("MyStamp") do
@@ -115,11 +115,11 @@
stamps = PDF::Inspector::XObject.analyze(@pdf.render)
stamps.xobject_streams[:Stamp1].data.chomp.should =~ /q(.|\s)*Q\Z/
end
-
+
it "should not add to the page graphic state stack " do
create_pdf
@pdf.state.page.stack.stack.size.should == 1
-
+
@pdf.create_stamp("MyStamp") do
@pdf.save_graphics_state
@pdf.save_graphics_state
@@ -129,7 +129,7 @@
end
@pdf.state.page.stack.stack.size.should == 1
end
-
+
it "should be able to change fill and stroke colors within the stamp stream" do
create_pdf
@pdf.create_stamp("MyStamp") do
@@ -142,7 +142,7 @@
stamp_stream.should.include "/DeviceCMYK cs\n1.000 1.000 0.200 0.000 scn"
stamp_stream.should.include "/DeviceCMYK CS\n1.000 1.000 0.200 0.000 SCN"
end
-
+
it "should save the color space even when same as current page color space" do
create_pdf
@pdf.stroke_color(100, 100, 20, 0)
@@ -154,6 +154,6 @@
stamp_stream = stamps.xobject_streams[:Stamp1].data
stamp_stream.should.include "/DeviceCMYK CS\n1.000 1.000 0.200 0.000 SCN"
end
-
+
end
diff --git a/spec/stroke_styles_spec.rb b/spec/stroke_styles_spec.rb
index e6e5ae14d..cca0ed947 100644
--- a/spec/stroke_styles_spec.rb
+++ b/spec/stroke_styles_spec.rb
@@ -7,7 +7,7 @@
it "cap_style should be :butt" do
@pdf.cap_style.should == :butt
end
-
+
it "join_style should be :miter" do
@pdf.join_style.should == :miter
end
@@ -19,12 +19,12 @@
describe "Cap styles" do
before(:each) { create_pdf }
-
+
it "should be able to use assignment operator" do
@pdf.cap_style = :round
@pdf.cap_style.should == :round
end
-
+
describe "#cap_style(:butt)" do
it "rendered PDF should include butt style cap" do
@pdf.cap_style(:butt)
@@ -60,12 +60,12 @@
describe "Join styles" do
before(:each) { create_pdf }
-
+
it "should be able to use assignment operator" do
@pdf.join_style = :round
@pdf.join_style.should == :round
end
-
+
describe "#join_style(:miter)" do
it "rendered PDF should include miter style join" do
@pdf.join_style(:miter)
@@ -101,7 +101,7 @@
describe "Dashes" do
before(:each) { create_pdf }
-
+
it "should be able to use assignment operator" do
@pdf.dash = 2
@pdf.should.be.dashed
@@ -151,7 +151,7 @@
dashes.stroke_dash.should == [[], 0]
end
end
-
+
it "should carry the current dash settings over to new pages" do
@pdf.dash(2)
@pdf.start_new_page
@@ -159,19 +159,19 @@
dashes.stroke_dash_count.should == 2
dashes.stroke_dash.should == [[2, 2], 0]
end
-
+
describe "#dashed?" do
-
+
it "an initial document should not be dashed" do
@pdf.dashed?.should == false
end
-
+
it "should return true if any of the currently active settings are dashed" do
@pdf.dash(2)
@pdf.save_graphics_state
@pdf.dashed?.should == true
end
-
+
it "should return false if the document was most recently undashed" do
@pdf.dash(2)
@pdf.save_graphics_state
@@ -179,7 +179,7 @@
@pdf.save_graphics_state
@pdf.dashed?.should == false
end
-
+
it "should return true when restoring to a state that was dashed" do
@pdf.dash(2)
@pdf.save_graphics_state
@@ -187,7 +187,7 @@
@pdf.restore_graphics_state
@pdf.dashed?.should == true
end
-
+
end
end
diff --git a/spec/table_spec.rb b/spec/table_spec.rb
index b613032ed..7a4dcb796 100644
--- a/spec/table_spec.rb
+++ b/spec/table_spec.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
-require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
+require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
require 'set'
describe "Prawn::Table" do
@@ -30,7 +30,7 @@
data = [["foo","bar"],["baz",""]]
@pdf.table(data)
}.should.not.raise
- end
+ end
it "should allow a table with a header but no body" do
lambda { @pdf.table([["Header"]], :header => true) }.should.not.raise
@@ -97,14 +97,14 @@
end
it "should select rows by number or range" do
- Set.new(@table.row(0).map { |c| c.content }).should ==
+ Set.new(@table.row(0).map { |c| c.content }).should ==
Set.new(%w[R0C0 R0C1])
- Set.new(@table.rows(0..1).map { |c| c.content }).should ==
+ Set.new(@table.rows(0..1).map { |c| c.content }).should ==
Set.new(%w[R0C0 R0C1 R1C0 R1C1])
end
it "should select rows by array" do
- Set.new(@table.rows([0, 1]).map { |c| c.content }).should ==
+ Set.new(@table.rows([0, 1]).map { |c| c.content }).should ==
Set.new(%w[R0C0 R0C1 R1C0 R1C1])
end
@@ -118,14 +118,14 @@
end
it "should select columns by number or range" do
- Set.new(@table.column(0).map { |c| c.content }).should ==
+ Set.new(@table.column(0).map { |c| c.content }).should ==
Set.new(%w[R0C0 R1C0])
- Set.new(@table.columns(0..1).map { |c| c.content }).should ==
+ Set.new(@table.columns(0..1).map { |c| c.content }).should ==
Set.new(%w[R0C0 R0C1 R1C0 R1C1])
end
it "should select columns by array" do
- Set.new(@table.columns([0, 1]).map { |c| c.content }).should ==
+ Set.new(@table.columns([0, 1]).map { |c| c.content }).should ==
Set.new(%w[R0C0 R0C1 R1C0 R1C1])
end
@@ -143,7 +143,7 @@
end
it "should accept a filter block, returning a cell proxy" do
- @table.cells.filter { |c| c.content =~ /R0/ }.column(1).map{ |c|
+ @table.cells.filter { |c| c.content =~ /R0/ }.column(1).map{ |c|
c.content }.should == ["R0C1"]
end
@@ -253,13 +253,13 @@
"column widths within a single table" do
hpad, fs = 10, 6
stretchy_columns = 2
-
+
col0_width = 50
col1_width = @pdf.width_of("foo", :size => fs)
col2_width = @pdf.width_of("foobar", :size => fs)
col3_width = 150
- table = Prawn::Table.new( [%w[snake foo b apple],
+ table = Prawn::Table.new( [%w[snake foo b apple],
%w[kitten d foobar banana]], @pdf,
:cell_style => { :padding => hpad, :size => fs }) do
@@ -267,8 +267,8 @@
column(3).width = col3_width
end
- table.width.should == col1_width + col2_width +
- 2*stretchy_columns*hpad +
+ table.width.should == col1_width + col2_width +
+ 2*stretchy_columns*hpad +
col0_width + col3_width
end
@@ -277,7 +277,7 @@
col1_width = 20
col3_width = 60
- table = Prawn::Table.new( [["snake", "foo", "b",
+ table = Prawn::Table.new( [["snake", "foo", "b",
"some long, long text that will wrap"],
%w[kitten d foobar banana]], @pdf,
:width => 150) do
@@ -298,7 +298,7 @@
expected_width = @pdf.margin_box.width
data = [
['This is a column with a lot of text that should comfortably exceed '+
- 'the width of a normal document margin_box width', 'Some more text',
+ 'the width of a normal document margin_box width', 'Some more text',
'and then some more', 'Just a bit more to be extra sure']
]
table = Prawn::Table.new(data, @pdf)
@@ -311,20 +311,20 @@
expected_width = @pdf.margin_box.width
data = [
['This is a column with a lot of text that should comfortably exceed '+
- 'the width of a normal document margin_box width', 'Some more text',
+ 'the width of a normal document margin_box width', 'Some more text',
'and then some more', 'Just a bit more to be extra sure']
]
table = Prawn::Table.new(data, @pdf) { column(1).width = 100 }
table.width.should == expected_width
end
-
+
it "scales down only the non-preset column widths when the natural width" +
"exceeds the maximum width of the margin_box" do
expected_width = @pdf.margin_box.width
data = [
['This is a column with a lot of text that should comfortably exceed '+
- 'the width of a normal document margin_box width', 'Some more text',
+ 'the width of a normal document margin_box width', 'Some more text',
'and then some more', 'Just a bit more to be extra sure']
]
table = Prawn::Table.new(data, @pdf) { column(1).width = 100; column(3).width = 50 }
@@ -371,7 +371,7 @@
it "should be the width of the :width parameter" do
expected_width = 300
- table = Prawn::Table.new( [%w[snake foo b apple],
+ table = Prawn::Table.new( [%w[snake foo b apple],
%w[kitten d foobar banana]], @pdf,
:width => expected_width)
@@ -382,7 +382,7 @@
expected_width = 400
data = [
['This is a column with a lot of text that should comfortably exceed '+
- 'the width of a normal document margin_box width', 'Some more text',
+ 'the width of a normal document margin_box width', 'Some more text',
'and then some more', 'Just a bit more to be extra sure']
]
table = Prawn::Table.new(data, @pdf, :width => expected_width)
@@ -394,7 +394,7 @@
expected_width = 400
data = [
['This is a column with a lot of text that should comfortably exceed '+
- 'the width of a normal document margin_box width', 'Some more text',
+ 'the width of a normal document margin_box width', 'Some more text',
'and then some more', 'Just a bit more to be extra sure']
]
table = Prawn::Table.new(data, @pdf, :width => expected_width) do
@@ -445,9 +445,9 @@
(t.height - 10).should.be < h*1.5
end
- it "should have a height of n rows" do
+ it "should have a height of n rows" do
data = [["foo"],["bar"],["baaaz"]]
-
+
vpad = 4
origin = @pdf.y
@pdf.table data, :cell_style => { :padding => vpad }
@@ -610,7 +610,7 @@
it "should default to {} for the hash argument" do
stylable = stub()
stylable.expects(:style).with({}).once
-
+
Prawn::Document.new do
table([["x"]]) { style(stylable) }
end
@@ -628,12 +628,12 @@
it "should ignore headers" do
data = [["header"], ["foo"], ["bar"], ["baz"]]
pdf = Prawn::Document.new
- t = pdf.table(data, :header => true,
+ t = pdf.table(data, :header => true,
:row_colors => ['cccccc', 'ffffff']) do
row(0).background_color = '333333'
end
- t.cells.map{|x| x.background_color}.should ==
+ t.cells.map{|x| x.background_color}.should ==
%w[333333 cccccc ffffff cccccc]
end
@@ -654,7 +654,7 @@
it "should set the x-position of each cell based on widths" do
@table = @pdf.table([["foo", "bar", "baz"]])
-
+
x = 0
(0..2).each do |col|
cell = @table.cells[0, col]
@@ -734,7 +734,7 @@
describe "in stretchy bounding boxes" do
it "should draw all cells on a row at the same y-position" do
pdf = Prawn::Document.new
-
+
text_y = pdf.y.to_i - 5 # text starts 5pt below current y pos (padding)
pdf.bounding_box([0, pdf.cursor], :width => pdf.bounds.width) do
@@ -753,7 +753,7 @@
data = [["a", "b"], ["foo","bar"],["baz","bang"]]
@pdf = Prawn::Document.new
@pdf.table(data, :header => true)
- output = PDF::Inspector::Text.analyze(@pdf.render)
+ output = PDF::Inspector::Text.analyze(@pdf.render)
output.strings.should == data.flatten
end
@@ -762,7 +762,7 @@
headers = ["baz","foobar"]
@pdf = Prawn::Document.new
@pdf.table([headers] + data, :header => true)
- output = PDF::Inspector::Text.analyze(@pdf.render)
+ output = PDF::Inspector::Text.analyze(@pdf.render)
output.strings.should == headers + data.flatten[0..-3] + headers +
data.flatten[-2..-1]
end
@@ -771,7 +771,7 @@
@pdf = Prawn::Document.new
@pdf.y = 0
@pdf.table([["Header"], ["Body"]], :header => true)
- output = PDF::Inspector::Text.analyze(@pdf.render)
+ output = PDF::Inspector::Text.analyze(@pdf.render)
output.strings.should == ["Header", "Body"]
end
end
@@ -796,7 +796,7 @@
it "has a subtable accessor" do
@table.cells[0, 0].subtable.should == @subtable
end
-
+
it "determines its dimensions from the subtable" do
@table.cells[0, 0].width.should == @subtable.width
@table.cells[0, 0].height.should == @subtable.height
@@ -805,12 +805,12 @@
end
describe "An invalid table" do
-
+
before(:each) do
@pdf = Prawn::Document.new
@bad_data = ["Single Nested Array"]
end
-
+
it "should raise error when invalid table data is given" do
assert_raises(Prawn::Errors::InvalidTableData) do
@pdf.table(@bad_data)
@@ -823,7 +823,7 @@
@pdf = Prawn::Document.new
@pdf.table(data)
}.should.raise( Prawn::Errors::EmptyTable )
- end
+ end
it "should raise an EmptyTableError with nil table data" do
lambda {
@@ -831,7 +831,7 @@
@pdf = Prawn::Document.new
@pdf.table(data)
}.should.raise( Prawn::Errors::EmptyTable )
- end
+ end
end
diff --git a/spec/template_spec.rb b/spec/template_spec.rb
index 9a0f5346c..c5ef46cec 100644
--- a/spec/template_spec.rb
+++ b/spec/template_spec.rb
@@ -40,7 +40,7 @@
:bottom => 36 }
-
+
end
it "should not add an extra restore_graphics_state operator to the end of any content stream" do
@@ -57,7 +57,7 @@
data.include?("QQ").should == false
end
end
-
+
it "should have a single page object if importing a single page template" do
filename = "#{Prawn::DATADIR}/pdfs/hexagon.pdf"
@@ -166,19 +166,19 @@
describe "Document#start_new_page with :template option" do
filename = "#{Prawn::BASEDIR}/spec/data/curves.pdf"
-
+
it "should set the imported page's parent to the document pages catalog" do
@pdf = Prawn::Document.new()
@pdf.start_new_page(:template => filename)
@pdf.state.page.dictionary.data[:Parent].should == @pdf.state.store.pages
end
-
+
it "should set start the Y cursor at the top of the page" do
@pdf = Prawn::Document.new()
@pdf.start_new_page(:template => filename)
(@pdf.y == nil).should == false
end
-
+
it "should respect margins set by Prawn" do
@pdf = Prawn::Document.new(:margin => 0)
@pdf.start_new_page(:template => filename)
@@ -199,7 +199,7 @@
:top => 36,
:bottom => 36 }
end
-
+
it "should not add an extra restore_graphics_state operator to the end of any content stream" do
@pdf = Prawn::Document.new
@pdf.start_new_page(:template => filename)
@@ -213,7 +213,7 @@
data.include?("QQ").should == false
end
end
-
+
it "should have two content streams if importing a single page template" do
filename = "#{Prawn::DATADIR}/pdfs/hexagon.pdf"
@pdf = Prawn::Document.new()
@@ -224,7 +224,7 @@
template_page = hash[pages[1]]
template_page[:Contents].size.should == 2
end
-
+
it "should have balance q/Q operators on all content streams" do
filename = "#{Prawn::DATADIR}/pdfs/hexagon.pdf"
@@ -241,7 +241,7 @@
data.scan("Q").size.should == 1
end
end
-
+
it "should allow text to be added to a single page template" do
@pdf = Prawn::Document.new()
@@ -252,7 +252,7 @@
text = PDF::Inspector::Text.analyze(@pdf.render)
text.strings.first.should == "Adding some text"
end
-
+
it "should allow PDFs with page resources behind an indirect object to be used as templates" do
filename = "#{Prawn::DATADIR}/pdfs/resources_as_indirect_object.pdf"
@@ -265,7 +265,7 @@
all_text = text.strings.join
all_text.include?("Adding some text").should == true
end
-
+
it "should correctly add a TTF font to a template that has existing fonts" do
filename = "#{Prawn::DATADIR}/pdfs/contains_ttf_font.pdf"
@pdf = Prawn::Document.new()
@@ -283,7 +283,7 @@
fonts = resources[:Font]
fonts.size.should == 2
end
-
+
context "using template_page option" do
it "uses the specified page option" do
filename = "#{Prawn::DATADIR}/pdfs/multipage_template.pdf"
diff --git a/spec/text_box_spec.rb b/spec/text_box_spec.rb
index d2743b889..1ee6f2844 100644
--- a/spec/text_box_spec.rb
+++ b/spec/text_box_spec.rb
@@ -116,7 +116,7 @@
end
it "should default to document-wide leading if no" +
"leading option is provided" do
-
+
end
end
@@ -517,7 +517,7 @@
:document => @pdf
}
end
-
+
it "printed text should match requested text, except that preceding and " +
"trailing white space will be stripped from each line, and newlines may " +
"be inserted" do
@@ -525,7 +525,7 @@
text_box.render
text_box.text.gsub("\n", " ").should == @text.strip
end
-
+
it "render should return an empty string because no text remains unprinted" do
text_box = Prawn::Text::Box.new(@text, @options)
text_box.render.should == ""
@@ -551,7 +551,7 @@
:document => @pdf
}
end
-
+
it "should have the expected height" do
expected_height = @options.delete(:height)
text_box = Prawn::Text::Box.new(@text, @options)
@@ -608,7 +608,7 @@
describe "Text::Box printing UTF-8 string with higher bit characters" do
before(:each) do
- create_pdf
+ create_pdf
@text = "©"
# not enough height to print any text, so we can directly compare against
# the input string
@@ -663,7 +663,7 @@
describe "Text::Box with more text than can fit in the box" do
before(:each) do
- create_pdf
+ create_pdf
@text = "Oh hai text rect. " * 30
@bounding_height = 162.0
@options = {
@@ -672,7 +672,7 @@
:document => @pdf
}
end
-
+
context "truncated overflow" do
before(:each) do
@options[:overflow] = :truncate
@@ -710,7 +710,7 @@
end
end
end
-
+
context "truncated with text and size taken from the manual" do
it "should return the right text" do
@text = "This is the beginning of the text. It will be cut somewhere and " +
@@ -809,8 +809,8 @@
end
-describe "drawing bounding boxes" do
- before(:each) { create_pdf }
+describe "drawing bounding boxes" do
+ before(:each) { create_pdf }
it "should restore the margin box when bounding box exits" do
margin_box = @pdf.bounds
@@ -845,7 +845,7 @@
text_box.text.should == "hello\nworld"
end
end
-
+
describe "Text::Box wrapping" do
before(:each) do
create_pdf
diff --git a/spec/text_spec.rb b/spec/text_spec.rb
index 1a4624f53..2741ab3a3 100644
--- a/spec/text_spec.rb
+++ b/spec/text_spec.rb
@@ -256,7 +256,7 @@
it "should raise an exception when an unknown font is used" do
lambda { @pdf.font "Pao bu" }.should.raise(Prawn::Errors::UnknownFont)
end
-
+
it "should not raise an exception when providing Pathname instance as font" do
lambda {
@pdf.font Pathname.new("#{Prawn::DATADIR}/fonts/comicsans.ttf")
diff --git a/spec/transparency_spec.rb b/spec/transparency_spec.rb
index 8c77ab605..590acfb02 100644
--- a/spec/transparency_spec.rb
+++ b/spec/transparency_spec.rb
@@ -1,4 +1,4 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
+require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
module TransparencyHelper
def make_transparent(opacity, stroke_opacity=opacity)
@@ -17,7 +17,7 @@ def make_transparent(opacity, stroke_opacity=opacity)
str = @pdf.render
str[0,8].should == "%PDF-1.4"
end
-
+
it "a new extended graphics state should be created for "+
"each unique transparency setting" do
create_pdf
@@ -27,7 +27,7 @@ def make_transparent(opacity, stroke_opacity=opacity)
extgstates = PDF::Inspector::ExtGState.analyze(@pdf.render).extgstates
extgstates.length.should == 2
end
-
+
it "a new extended graphics state should not be created for "+
"each duplicate transparency setting" do
create_pdf
@@ -70,7 +70,7 @@ def make_transparent(opacity, stroke_opacity=opacity)
extgstate[:opacity].should == 1.0
extgstate[:stroke_opacity].should == 1.0
end
-
+
describe "with more than one page" do
include TransparencyHelper
@@ -78,7 +78,7 @@ def make_transparent(opacity, stroke_opacity=opacity)
create_pdf
make_transparent(0.5, 0.2)
@pdf.start_new_page
- make_transparent(0.5, 0.2)
+ make_transparent(0.5, 0.2)
extgstates = PDF::Inspector::ExtGState.analyze(@pdf.render).extgstates
extgstate = extgstates[0]
extgstates.length.should == 2
diff --git a/www/index.html b/www/index.html
index 7b6eb1c42..2724eafb4 100644
--- a/www/index.html
+++ b/www/index.html
@@ -1,4 +1,4 @@
-
+
@@ -6,43 +6,43 @@
-
+
-
+
Prawn: Fast, Nimble PDF Generation For Ruby
-Installable via RubyGems : gem install prawn
-
-
+Installable via RubyGems : gem install prawn
+
+
-Building printable documents doesn't have to be hard
+Building printable documents doesn't have to be hard
- If you've ever needed to produce PDF documents before, in Ruby or another language, you probably know how much it can suck. Prawn takes the pain out of generating beautiful printable documents, while still remaining fast, tiny and nimble. It is also named after a majestic sea creature, and that has to count for something.
+ If you've ever needed to produce PDF documents before, in Ruby or another language, you probably know how much it can suck. Prawn takes the pain out of generating beautiful printable documents, while still remaining fast, tiny and nimble. It is also named after a majestic sea creature, and that has to count for something.
The features you need, without all the complexity
-
+
In addition to being the fastest pure Ruby PDF generation library, Prawn has features that might prevent you from hating your job. The samples below give
a taste of what Prawn based programs looks like, click the code to reveal the PDF it generates.
-
-
+
+
-- Built in support for UTF-8
-
+
Internationalized text in Prawn is as simple as providing UTF-8 strings for it to render, assuming you've got a Unicode aware TTF font handy. For those who are running on Ruby 1.9, any encoding that can be converted to UTF-8 will work out of the box!
-
+
@@ -56,22 +56,22 @@ -- Built in support for UTF-8
-- Easy image embedding
-
+
Prawn makes embedding JPEG and PNG images a breeze. With support for alpha transparency, easy positioning and scaling of images, you'll have no problem
including all the graphics you need in your documents.
-
+
Prawn("image2.pdf", :page_layout => :landscape) do
- pigs = "/data/images/pigs.jpg"
- image pigs, :at => [50,450], :width => 450
+ pigs = "/data/images/pigs.jpg"
+ image pigs, :at => [50,450], :width => 450
dice = "/data/images/dice.png"
- image dice, :at => [50, 450], :scale => 0.75
+ image dice, :at => [50, 450], :scale => 0.75
end
@@ -83,13 +83,13 @@ -- Flexible table drawing
Prawn has built in support for rendering text in the form of tables, providing
-basic reporting functionality. This lets users focus on customizing their
+basic reporting functionality. This lets users focus on customizing their
documents rather than forcing them to write a ton of low level graphics drawing
code.
-
+
-
+
Prawn("fancy_table.pdf") do
@@ -108,19 +108,19 @@ -- Flexible table drawing
end
-
+
-- Simplified content positioning
-
+
Anyone who has done work with a low level graphics engine knows that doing coordinate math isn't fun. Prawn simplifies this by allowing you to box off a sub-section of the document and treat it as its own mini-coordinate space. This means that all positioning is relative, making it easy to move things around your document while keeping your code clean.
-Text can also be flowed within these sectioned off bounding boxes, so this
+Text can also be flowed within these sectioned off bounding boxes, so this
makes it trivial to generate columns of text on the fly.
-
+
-
+
Prawn("bounding_boxes.pdf") do
bounding_box [100,600], :width => 200 do
@@ -136,49 +136,49 @@ -- Simplified content positioning
circle_at [100,100], :radius => 100
line bounds, bounds
line bounds, bounds
- end
+ end
bounding_box [50,150], :width => 100, :height => 100 do
stroke_rectangle bounds, bounds, bounds
- end
+ end
end
end
-
+
-- And loads more to come
Prawn is currently alpha-level software under active development. New features are cropping up every day, and we expect to see loads of cool things in the near future including integration with the popular Ruby Reports project. For now, you can keep
an eye on the latest new features by checking out the examples distributed
-with the source, which include the code samples shown above and much, much more!
+with the source, which include the code samples shown above and much, much more!
-Supported by the Ruby Community
+Supported by the Ruby Community
-The development on Prawn is in part made possible through donations from the community to
-Gregory Brown's Ruby Mendicant project, but quickly outgrew its humble beginnings.
+The development on Prawn is in part made possible through donations from the community to
+Gregory Brown's Ruby Mendicant project, but quickly outgrew its humble beginnings.
Since the project began in April 2008, the project has seen contributions in the form of code, bug reports, and feature requests from a whole bunch of Ruby hackers. You can find many of their contributions by checking out the Github
-network graph for the project. Although several have contributed patches to Prawn, special thanks goes out to James Healy and Michael Daines for being instrumental to the forward development of the library.
+network graph for the project. Although several have contributed patches to Prawn, special thanks goes out to James Healy and Michael Daines for being instrumental to the forward development of the library.
Many people have expressed interest in using Prawn within their Rails applications, and for this purpose, you might be interested in checking out yet another community contribution, thorny_sun's Prawnto Rails plugin. Although this is not officially part of Prawn, we'll do what we can to make sure this plugin continues to work as things move forward
Please join us in the development of Prawn so that it can become the library of choice for PDF generation in Ruby. You can start by getting in touch with us on the mailing list or stopping by to chat in the #prawn channel on irc.freenode.net. There is lots left to be done, and we could use your help!
-
+
What are you waiting for?
-It's time to generate some PDFs. Get Prawn via RubyGems with gem install prawn or clone us at git://github.com/sandal/prawn.git
+It's time to generate some PDFs. Get Prawn via RubyGems with gem install prawn or clone us at git://github.com/sandal/prawn.git
-
+
-
+
Prawn is Free Software under the License of Ruby, developed by Gregory Brown and the Ruby community.
The Prawn logo was created by maso and is distributed under
- the CC Attribution-Share Alike license.
-
-
+ the CC Attribution-Share Alike license.
+
+
-
+
+
diff --git a/www/prawn-Chinese.html b/www/prawn-Chinese.html
index debe022b2..e217a5443 100644
--- a/www/prawn-Chinese.html
+++ b/www/prawn-Chinese.html
@@ -1,101 +1,101 @@
-
+
-
+
-
+
Prawn: 小巧的Ruby PDF生成库
-从RubyGems安装 : gem install prawn
-
-
+从RubyGems安装 : gem install prawn
+
+
-轻而易举创建PDF打印文档
-
+轻而易举创建PDF打印文档
+
- 在包括Ruby在内的几乎所有编程语言中,将文档转换成PDF格式一直是一件令人头痛的事情。Prawn可以帮你大大减轻这种痛苦,并且仍然保持高效简洁。Prawn, 中文意为虾,也暗含了小巧迅速的意味。
+ 在包括Ruby在内的几乎所有编程语言中,将文档转换成PDF格式一直是一件令人头痛的事情。Prawn可以帮你大大减轻这种痛苦,并且仍然保持高效简洁。Prawn, 中文意为虾,也暗含了小巧迅速的意味。
方便地获取所需功能
-
+
Prawn是 速度最快,功能最纯粹的基于Ruby的PDF生成类库。, 在接下来的内容中,你会看到Prawn的一些具体代码, 点击代码本身可以看到代码所产生的PDF文档。
-
-
+
+
-- 内置支持UTF-8
-
+
在Prawn中生成国际化文字和生成UTF-8字符串一样简单,当然前提条件是你有国际化文字的标准字体文件(Unicode aware TTF font)在你的系统中。使用Ruby 1.9的人,所有可以被转化成UTF-8的代码都可以直接使用。
-
+
-
+
-- 轻松的图像嵌入
-
+
在Prawn中插入JPEG和PNG格式的图像相当方便。Prawn支持Alpha透明,定位和缩放都可以很容易实现,从而使在文档中插入图像轻而易举。
-
+
-
+
-- 灵活的表格绘制
Prawn内置支持以表格的形式呈现文字,从而实现基本的报表功能。将用户从编写低端画图代码中解脱出来,而能够真正将精力用在编辑文档的内容上。。
-
+
-
+
-- 简化的定位系统
-
+
写过低端绘图软件的人一定记得处理好各种坐标系不是一件容易的事情。Prawn将这个过程大大简化。你可以将文档的任何一个部分界成一个独特的区域(bounding box),并拥有这个区域独立的坐标系。你可以在文档中随意移动这个区域的位置,但是这个区域内部组分的相对位置不会改变,从而保持了代码的简洁。在这样的特定区域内,文字也可以自动分行,所以在海报上分栏书写变得非常容易。
-
+
-- 更多功能即将实现
-Prawn现在只处于开发的初级阶段, 新的功能每天都会出现。在不久的将来我们会将它整合到现有的 Ruby报表软件系统(Ruport)。 如果你希望知道最新的功能,只需点击 例子和代码, 它包含上面显示的各种代码和更多其它有关的内容。
+Prawn现在只处于开发的初级阶段, 新的功能每天都会出现。在不久的将来我们会将它整合到现有的 Ruby报表软件系统(Ruport)。 如果你希望知道最新的功能,只需点击 例子和代码, 它包含上面显示的各种代码和更多其它有关的内容。
-来自Ruby社区的支持
+来自Ruby社区的支持
-Prawn的开发很大一部分是基于社区对Gregory Brown的 ”Ruby之乞“ 计划的捐赠。在人们的支持下,此计划一经产生就迅速成长了起来,并成了现实。
+Prawn的开发很大一部分是基于社区对Gregory Brown的 ”Ruby之乞“ 计划的捐赠。在人们的支持下,此计划一经产生就迅速成长了起来,并成了现实。
自从2008年四月Prawn开始之始,包括在代码的表达,错误的监察,以及功能的制定等各个方面都有Ruby爱好者们的积极地参与。你们可以从 Github
-network graph上找到他们的足迹。在为Prawn提供了插件的所有人中,特别感谢 James Healy 和 Michael Daines 为他们对Prawn的不可取代的贡献。
+network graph上找到他们的足迹。在为Prawn提供了插件的所有人中,特别感谢 James Healy 和 Michael Daines 为他们对Prawn的不可取代的贡献。
如果你希望能够在Rails的程序中用到Prawn,你可以试试使用另一个社区产品,thorny_sun的 Prawnto Rails的插件。虽然这个并不是Prawn的正式部件,我们会尽力使这个插件保持发挥作用。
请加入我们开发Prawn的队伍,使它真正成为符合客户选择的生成PDF的Ruby类库。 你可以加入我们的 邮件组 或者加入我们在irc.freenode.net上 #prawn 频道的聊天组。需要做的事情还很多,你的帮助会使我们离目标更近一步!
-
+
快来一试!
从RubyGems安装: gem install prawn 从github下载: 地址为: git://github.com/sandal/prawn.git
-
+
-
+
Prawn is Free Software under the License of Ruby, developed by Gregory Brown and the Ruby community.
The Prawn logo was created by maso and is distributed under
- the CC Attribution-Share Alike license.
-
-
+ the CC Attribution-Share Alike license.
+
+
-
+
+
diff --git a/www/prawn.css b/www/prawn.css
index 17bfd5c71..99baefe0e 100644
--- a/www/prawn.css
+++ b/www/prawn.css
@@ -6,53 +6,53 @@
body {
font: Verdana, "Lucida Grande", "Lucida Sans", sans-serif;
background-color: #000000;
- color: #ffffff;
+ color: #ffffff;
margin-bottom: 1em;
-}
+}
h2, h3, h4, h5, h6, p, pre, blockquote, form, fieldset, table, ul {
margin: 1em 0;
-}
+}
h2 {
font-size: 1.75em;
}
-h2, h3 {
+h2, h3 {
color: #00bb77;
-}
+}
h1 {
- color: #bb5566;
- font-size: 1.1em;
+ color: #bb5566;
+ font-size: 1.1em;
margin-top: 0.5em;
-}
+}
-a {
- color: #ffffff;
+a {
+ color: #ffffff;
text-decoration: none;
- outline: none;
+ outline: none;
}
-a:visited {
+a:visited {
color: #ffffff;
}
-a:hover, a:active {
+a:hover, a:active {
color: #2299ff;
}
-
+
a img {
border:none;
}
-#contents {
+#contents {
background-color: #101010;
width: 740px;
margin: 0 auto;
border: 1px solid #fff;
margin-top: 1em;
padding: 1em 1em 1em 3em;
-}
+}
#sidebar {
width: 180px;
@@ -62,24 +62,24 @@ a img {
}
-#screenshots {
+#screenshots {
margin-top: 2em;
float: right;
-}
+}
-ul {
- text-align: center;
+ul {
+ text-align: center;
float: right;
-}
+}
-li {
+li {
display: inline;
- border-top: 1px solid #fff;
- border-right: 1px solid #fff;
- border-bottom: 1px solid #666;
- border-left: 1px solid #666;
+ border-top: 1px solid #fff;
+ border-right: 1px solid #fff;
+ border-bottom: 1px solid #666;
+ border-left: 1px solid #666;
margin-right: 5px;
- padding-left: 10px;
+ padding-left: 10px;
padding-right: 10px;
color: #fff;
font-weight: bold;
diff --git a/www/twilight.css b/www/twilight.css
index 263f4e2c6..c2c0a0efe 100644
--- a/www/twilight.css
+++ b/www/twilight.css
@@ -4,7 +4,7 @@
/* Stylesheet generated from TextMate theme
*
* Twilight
- *
+ *
*
*/