Skip to content

Commit

Permalink
Initial hack to get PDFKit to work
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Bale committed Nov 9, 2010
1 parent ce714e2 commit 105647c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ So far, ShowOff has been used in the following presentations (and many others):
* Red Dirt Ruby Conference May 2010 - Plain Old Tokyo Storage - Jeremy Hinegardner
http://github.com/copiousfreetime/plain-old-tokyo-storage-presentation
http://plain-old-tokyo-storage.heroku.com/
* Lambda Lounge - JavaScript Functions : The Good Parts - Idioms for Encapsulation and Inheritance - Scott Bale
* Lambda Lounge and StrangeLoop 2010 - JavaScript Functions : The Good Parts - Idioms for Encapsulation and Inheritance - Scott Bale
http://github.com/scottbale/JavaScript-Function-Idioms
* Open Source Bridge 2010 - Creating a low-cost clustered virtualization environment w/ Ganeti - Lance Albertson
http://github.com/ramereth/presentation-ganeti
Expand Down
31 changes: 27 additions & 4 deletions lib/showoff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
puts 'pdf generation disabled - install princely'
end

begin
require 'pdfkit'
rescue LoadError
puts 'pdf generation disabled - install PDFKit'
end

begin
require 'rdiscount'
rescue LoadError
Expand Down Expand Up @@ -290,12 +296,29 @@ def onepage(static=false)

def pdf(static=false)
@slides = get_slides_html(static)
@no_js = true
@no_js = false
html = erb :onepage
p = Princely.new
# p = Princely.new
# TODO make a random filename
p.pdf_from_string_to_file(html, '/tmp/preso.pdf')
File.new('/tmp/preso.pdf')
# p.pdf_from_string_to_file(html, '/tmp/preso.pdf')
# File.new('/tmp/preso.pdf')


# PDFKit.new takes the HTML and any options for wkhtmltopdf
# run `wkhtmltopdf --extended-help` for a full list of options
kit = PDFKit.new(html, :page_size => 'Letter', :orientation => 'Landscape')
# kit.stylesheets << '/css/showoff.css'

# Git an inline PDF
# pdf = kit.to_pdf

# Save the PDF to a file
file = kit.to_file('/tmp/preso.pdf')

# Add any kind of option through meta tags
# PDFKit.new('<html><head><meta name="pdfkit-page_size" content="Letter")


end

end
Expand Down
1 change: 1 addition & 0 deletions public/js/sh_html.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions public/js/sh_javascript.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion views/onepage.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<% end %>

<% if !@no_js %>
<%= inline_js(['jquery-1.4.2.min.js', 'jquery-print.js', 'showoff.js', 'onepage.js', 'sh_main.min.js', 'core.js', 'showoffcore.js'], 'public/js') %>
<%= inline_js(['jquery-1.4.2.min.js', 'jquery-print.js', 'showoff.js', 'onepage.js', 'sh_main.min.js', 'sh_javascript.min.js', 'sh_html.min.js', 'core.js', 'showoffcore.js'], 'public/js') %>
<script type="text/javascript">
$(document).ready(function() {
setupOnePage()
Expand Down

0 comments on commit 105647c

Please sign in to comment.