Created
March 4, 2009 06:42
-
-
Save geelen/73748 to your computer and use it in GitHub Desktop.
This file contains 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
desc "Grab the html files and pdf-ize them through safari" | |
task :html_to_pdf => ['main.html', 'scalpel.html'] do | |
require 'rbosa' | |
run "rm ~/Desktop/cups-pdf/*", "Cleaning ~/Desktop/cups-pdf" | |
app = OSA.app('Safari') | |
files.each { |file| | |
app.make OSA::Safari::Document, :with_properties => { :url => "file://localhost/Users/glen/work/boost-doc/#{file}.html" } | |
sleep 1 while (app.do_javascript("document.readyState", app.documents[0]) != "complete") | |
app.print app.documents[0], :print_dialog => false | |
output_file = nil | |
sleep 1 while (output_file = Dir[ENV["HOME"] + "/Desktop/cups-pdf/*"].first).nil? | |
app.close app.documents[0] | |
run "mv #{output_file} #{file}.html.pdf", "Moving file to #{file}.html.pdf" | |
run "open #{file}.html.pdf", "Opening pdf" | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment