Skip to content
Browse files

Initial commit (contains a patched flying saucer to support :last-child)

  • Loading branch information...
0 parents commit 72b916a3e04a90891db27bebc9fa23761e2c1580 @wycats committed Sep 17, 2008
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2008 Yehuda Katz
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5 README.markdown
@@ -0,0 +1,5 @@
+UFO
+===
+
+A gem that provides a Ruby binding to the flying saucer Java library for creating PDFs out
+of HTML and CSS.
50 Rakefile
@@ -0,0 +1,50 @@
+require 'rubygems'
+require 'rake/gempackagetask'
+require 'rubygems/specification'
+require 'date'
+
+GEM = "flying_saucer"
+GEM_VERSION = "0.0.1"
+AUTHOR = "Your Name"
+EMAIL = "Your Email"
+HOMEPAGE = "http://example.com"
+SUMMARY = "A gem that provides..."
+
+spec = Gem::Specification.new do |s|
+ s.name = GEM
+ s.version = GEM_VERSION
+ s.platform = Gem::Platform::RUBY
+ s.has_rdoc = true
+ s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
+ s.summary = SUMMARY
+ s.description = s.summary
+ s.author = AUTHOR
+ s.email = EMAIL
+ s.homepage = HOMEPAGE
+
+ # Uncomment this to add a dependency
+ s.add_dependency "thor"
+
+ s.bindir = "bin"
+ s.executables = "make_pdf"
+
+ s.require_path = 'lib'
+ s.autorequire = GEM
+ s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs}/**/*")
+end
+
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.gem_spec = spec
+end
+
+desc "install the gem locally"
+task :install => [:package] do
+ sh %{sudo #{Gem.ruby} -S gem install pkg/#{GEM}-#{GEM_VERSION}}
+end
+
+desc "create a gemspec file"
+task :make_spec do
+ File.open("#{GEM}.gemspec", "w") do |file|
+ file.puts spec.to_ruby
+ end
+end
19 bin/make_pdf
@@ -0,0 +1,19 @@
+require "rubygems"
+require "thor"
+require "flying_saucer"
+
+class Saucer < Thor
+
+ desc "fly", "create a PDF"
+ def fly(input, output = "out.pdf")
+ puts "Rendering PDF..."
+ input_file = "#{File.expand_path(input)}"
+ File.open(output, 'w') do |file|
+ ITextRenderer.new.make_pdf(input, file)
+ end
+ puts "Done."
+ end
+
+end
+
+Saucer.start
7 lib/flying_saucer.rb
@@ -0,0 +1,7 @@
+require "java"
+require "flying_saucer/core-renderer"
+require "flying_saucer/itext_renderer"
+
+import org.jruby.util.IOOutputStream
+
+java.lang.System.set_property("java.awt.headless", "true")
BIN lib/flying_saucer/core-renderer.jar
Binary file not shown.
BIN lib/flying_saucer/itext-paulo-155.jar
Binary file not shown.
10 lib/flying_saucer/itext_renderer.rb
@@ -0,0 +1,10 @@
+require "flying_saucer/itext-paulo-155"
+import org.xhtmlrenderer.pdf.ITextRenderer
+
+class ITextRenderer
+ def make_pdf(input, file)
+ self.document = "file:#{File.expand_path(input)}"
+ self.layout
+ self.create_pdf(IOOutputStream.new(file))
+ end
+end
7 spec/flying_saucer_spec.rb
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/spec_helper'
+
+describe "flying_saucer" do
+ it "should do nothing" do
+ true.should == true
+ end
+end
2 spec/spec_helper.rb
@@ -0,0 +1,2 @@
+$TESTING=true
+$:.push File.join(File.dirname(__FILE__), '..', 'lib')

0 comments on commit 72b916a

Please sign in to comment.
Something went wrong with that request. Please try again.