Skip to content

Instantly share code, notes, and snippets.

View practicingruby's full-sized avatar

Gregory Brown practicingruby

View GitHub Profile
require "open-uri"
Prawn::Document.generate("remote_images.pdf") do
image open("http://prawn.majesticseacreature.com/media/prawn_logo.png")
end
#!/usr/bin/env ruby
require "pathname"
WORKING_DIR = Pathname.new(".").realpath
LOADER = %Q{
require "pathname"
Pathname.glob("#{WORKING_DIR}/vendor/**/**") do |dir|
lib = dir + "lib"
$LOAD_PATH.push(lib.directory? ? lib : dir)
require "open-uri"
Prawn::Document.generate("github-invoice.pdf", :top_margin => 68) do
text "Invoice / Receipt", :size => 24, :style => :bold
move_down 30
text "Account billed: defunkt (chris@ozmm.org)", :size => 14
move_down 20
require "enumerator"
module LazyStream
class Node
def initialize( head, &promise )
@head, @tail = head, promise
end
attr_reader :head
require "enumerator"
module LazyStream
class Node
def initialize( head, &promise )
@head, @tail = head, promise
end
attr_reader :head
# === Text Positioning Details:
#
# When using the :at parameter, Prawn will position your text by its
# baseline, and flow along a single line.
#
# When using automatic text flow, Prawn currently does a bunch of nasty
# hacks to get things to position nicely in bounding boxes, table cells,
# etc.
#
# For AFM fonts, the first line of text is positioned font.height below
DFONT_FILE = "#{Prawn::BASEDIR}/data/fonts/Action Man.dfont"
puts "There are #{Prawn::Font::DFont.font_count(DFONT_FILE)} fonts in #{DFONT_FILE}:"
Prawn::Font::DFont.named_fonts(DFONT_FILE).each do |name|
puts "* #{name}"
end
puts
puts "generating sample document in 'dfont.pdf'..."
Prawn::Document.generate "dfont.pdf" do
DFONT_FILE = "#{Prawn::BASEDIR}/data/fonts/Action Man.dfont"
puts "There are #{Prawn::Font::DFont.font_count(DFONT_FILE)} fonts in #{DFONT_FILE}:"
Prawn::Font::DFont.named_fonts(DFONT_FILE).each do |name|
puts "* #{name}"
end
puts
puts "generating sample document in 'dfont.pdf'..."
Prawn::Document.generate "dfont.pdf" do
sandal:prawn $ rake test
Prawn specs: Running on Ruby Version: 1.8.6
Loaded suite /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader
Started
..........................................................................................................................................................................................................
Finished in 33.949722 seconds.
202 tests, 338 assertions, 0 failures, 0 errors
# AS COMPARED TO:
sandal:prawn $ rake examples
Running Examples
Ran in 39.902182 s
sandal:prawn $ rake19 examples
Running Examples
Ran in 14.463586 s