lib/reportbuilder/builder/pdf.rb in reportbuilder-1.4.0 vs lib/reportbuilder/builder/pdf.rb in reportbuilder-1.4.1
- old
+ new
@@ -15,10 +15,11 @@
# * <tt>options</tt>: Hash of options.
def initialize(builder, options)
super
@pdf=Prawn::Document.new(options)
@pdf.font_size=@options[:font_size]
+
end
def self.code
%w{pdf}
end
@@ -34,29 +35,36 @@
:font_size=>12
}
end
# Add a paragraph of text.
def text(t)
-
@pdf.text(t)
end
# Add a header of level <tt>level</tt> with text <tt>t</tt>
# Level works similar to h
def header(level, t)
- @pdf.text t, :size=>15-level
+ @pdf.pad 5 do
+ @pdf.text t, {:size=>15-level*1.5,:align=>:center}
+ end
end
# Add preformatted text.
def preformatted(t)
@pdf.font("Courier") do
@pdf.text t
end
end
+ def at_end
+ @pdf.number_pages(@options[:number_pages], [@pdf.bounds.right - 50, 0] ) if @options[:numerate_pages]
+
+ end
# Returns pdf code for report
def out
+ at_end
@pdf.render
end
# Save pdf file
def save(filename)
+ at_end
@pdf.render_file(filename)
end
# Do nothing on this builder
def html(t)
# Nothing