This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # === 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "enumerator" | |
| module LazyStream | |
| class Node | |
| def initialize( head, &promise ) | |
| @head, @tail = head, promise | |
| end | |
| attr_reader :head |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "enumerator" | |
| module LazyStream | |
| class Node | |
| def initialize( head, &promise ) | |
| @head, @tail = head, promise | |
| end | |
| attr_reader :head |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "open-uri" | |
| Prawn::Document.generate("remote_images.pdf") do | |
| image open("http://prawn.majesticseacreature.com/media/prawn_logo.png") | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Prawn::Document.generate("span.pdf") do | |
| # Spans will typically be used outside of bounding boxes as a way to build | |
| # single columns of flowing text that span across pages. | |
| # | |
| span(350, :position => :center) do | |
| text "Here's some centered text in a 350 point column. " * 100 | |
| end | |
| # Spans are not really compatible with bounding boxes because they break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "enumerator" | |
| # tree is represented as: [[a,b,c,d],[e,f,g],[h,i],[j]] | |
| # (bottom up) | |
| # | |
| def max(tree) | |
| bottom = tree.shift | |
| pairs = bottom.enum_for(:each_cons, 2).to_a | |
| update = pairs.enum_for(:each_with_index).map do |pair,i| | |
| tree.first[i] + pair.max |