Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update for prawn-core 0.7.1

  • Loading branch information...
commit 9e48a60f15efd7cbec48e42dc3ddd446149441ac 1 parent bf3254c
@practicingruby authored
View
36 examples/page_layout/flowing_text_with_header_and_footer.rb
@@ -1,36 +0,0 @@
-# encoding: utf-8
-#
-# Multi-faceted example that demonstrates a document flowing between header
-# and footer regions. At the moment, headers and footers in Prawn are run
-# using the current font settings (among other things), for each page. This
-# means that it is important to non-destructively set your desired styling
-# within your headers and footers, as shown below.
-#
-# Future versions of Prawn may make this more convenient somehow.
-#
-require "#{File.dirname(__FILE__)}/../example_helper.rb"
-
-Prawn::Document.generate("flow_with_headers_and_footers.pdf") do
-
- header margin_box.top_left do
- font "Helvetica" do
- text "Here's My Fancy Header", :size => 25, :align => :center
- stroke_horizontal_rule
- end
- end
-
- footer [margin_box.left, margin_box.bottom + 25] do
- font "Helvetica" do
- stroke_horizontal_rule
- text "And here's a sexy footer", :size => 16
- end
- end
-
- bounding_box([bounds.left, bounds.top - 50],
- :width => bounds.width, :height => bounds.height - 100) do
- text "this is some flowing text " * 200
-
-
- end
-
-end
View
40 lib/prawn/layout/page.rb
@@ -47,46 +47,6 @@ def padded_box(margin, &block)
:height => bounds.height - (margin * 2), &block
end
- # A header is a LazyBoundingBox drawn relative to the margins that can be
- # repeated on every page of the document.
- #
- # Unless <tt>:width</tt> or <tt>:height</tt> are specified, the margin_box
- # width and height are used.
- #
- # header margin_box.top_left do
- # text "Here's My Fancy Header", :size => 25, :align => :center
- # stroke_horizontal_rule
- # end
- #
- def header(top_left,options={},&block)
- @header = repeating_page_element(top_left,options,&block)
- end
-
- # A footer is a LazyBoundingBox drawn relative to the margins that can be
- # repeated on every page of the document.
- #
- # Unless <tt>:width</tt> or <tt>:height</tt> are specified, the margin_box
- # width and height are used.
- #
- # footer [margin_box.left, margin_box.bottom + 25] do
- # stroke_horizontal_rule
- # text "And here's a sexy footer", :size => 16
- # end
- #
- def footer(top_left,options={},&block)
- @footer = repeating_page_element(top_left,options,&block)
- end
-
- private
-
- def repeating_page_element(top_left,options={},&block)
- r = LazyBoundingBox.new(self, translate(top_left),
- :width => options[:width] || margin_box.width,
- :height => options[:height] || margin_box.height )
- r.action(&block)
- return r
- end
-
class LazyBoundingBox < BoundingBox
# Defines the block to be executed by LazyBoundingBox#draw.
View
21 lib/prawn/table/cell.rb
@@ -129,12 +129,13 @@ def draw
margin = @border_width / 2.0
if @background_color
- @document.mask(:fill_color) do
- @document.fill_color @background_color
- h = borders.include?(:bottom) ?
- height - ( 2 * margin ) : height + margin
- @document.fill_rectangle [x, y ], width, h
- end
+ old_color = @document.fill_color || "000000"
+ @document.fill_color(@background_color)
+ h = borders.include?(:bottom) ?
+ height - ( 2 * margin ) : height + margin
+ @document.fill_rectangle [x, y ], width, h
+
+ @document.fill_color(old_color)
end
if @border_width > 0
@@ -185,10 +186,10 @@ def draw
options[:size] = @font_size if @font_size
options[:style] = @font_style if @font_style
- @document.mask(:fill_color) do
- @document.fill_color @text_color if @text_color
- @document.text @text, options
- end
+ old_color = @document.fill_color || "000000"
+ @document.fill_color @text_color if @text_color
+ @document.text @text, options
+ @document.fill_color "000000"
end
end
View
41 spec/page_layout_spec.rb
@@ -1,41 +0,0 @@
-# encoding: utf-8
-require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
-
-describe "When beginning each new page" do
-
- it "should execute codeblock given to Document#header" do
- call_count = 0
-
- pdf = Prawn::Document.new
- pdf.header(pdf.margin_box.top_left) do
- call_count += 1
- end
-
- pdf.start_new_page
- pdf.start_new_page
- pdf.render
-
- call_count.should == 3
- end
-
-end
-
-describe "When ending each page" do
-
- it "should execute codeblock given to Document#footer" do
-
- call_count = 0
-
- pdf = Prawn::Document.new
- pdf.footer([pdf.margin_box.left, pdf.margin_box.bottom + 50]) do
- call_count += 1
- end
-
- pdf.start_new_page
- pdf.start_new_page
- pdf.render
-
- call_count.should == 3
- end
-
-end
View
1  vendor/prawn-core
Please sign in to comment.
Something went wrong with that request. Please try again.