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
| #!/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("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
| 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
| # === 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
| 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
| 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: |
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
| sandal:prawn $ rake examples | |
| Running Examples | |
| Ran in 39.902182 s | |
| sandal:prawn $ rake19 examples | |
| Running Examples | |
| Ran in 14.463586 s | |