Skip to content

Commit 105647c

Browse files
author
Scott Bale
committed
Initial hack to get PDFKit to work
1 parent ce714e2 commit 105647c

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

README.rdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ So far, ShowOff has been used in the following presentations (and many others):
327327
* Red Dirt Ruby Conference May 2010 - Plain Old Tokyo Storage - Jeremy Hinegardner
328328
http://github.com/copiousfreetime/plain-old-tokyo-storage-presentation
329329
http://plain-old-tokyo-storage.heroku.com/
330-
* Lambda Lounge - JavaScript Functions : The Good Parts - Idioms for Encapsulation and Inheritance - Scott Bale
330+
* Lambda Lounge and StrangeLoop 2010 - JavaScript Functions : The Good Parts - Idioms for Encapsulation and Inheritance - Scott Bale
331331
http://github.com/scottbale/JavaScript-Function-Idioms
332332
* Open Source Bridge 2010 - Creating a low-cost clustered virtualization environment w/ Ganeti - Lance Albertson
333333
http://github.com/ramereth/presentation-ganeti

lib/showoff.rb

+27-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
puts 'pdf generation disabled - install princely'
1919
end
2020

21+
begin
22+
require 'pdfkit'
23+
rescue LoadError
24+
puts 'pdf generation disabled - install PDFKit'
25+
end
26+
2127
begin
2228
require 'rdiscount'
2329
rescue LoadError
@@ -290,12 +296,29 @@ def onepage(static=false)
290296

291297
def pdf(static=false)
292298
@slides = get_slides_html(static)
293-
@no_js = true
299+
@no_js = false
294300
html = erb :onepage
295-
p = Princely.new
301+
# p = Princely.new
296302
# TODO make a random filename
297-
p.pdf_from_string_to_file(html, '/tmp/preso.pdf')
298-
File.new('/tmp/preso.pdf')
303+
# p.pdf_from_string_to_file(html, '/tmp/preso.pdf')
304+
# File.new('/tmp/preso.pdf')
305+
306+
307+
# PDFKit.new takes the HTML and any options for wkhtmltopdf
308+
# run `wkhtmltopdf --extended-help` for a full list of options
309+
kit = PDFKit.new(html, :page_size => 'Letter', :orientation => 'Landscape')
310+
# kit.stylesheets << '/css/showoff.css'
311+
312+
# Git an inline PDF
313+
# pdf = kit.to_pdf
314+
315+
# Save the PDF to a file
316+
file = kit.to_file('/tmp/preso.pdf')
317+
318+
# Add any kind of option through meta tags
319+
# PDFKit.new('<html><head><meta name="pdfkit-page_size" content="Letter")
320+
321+
299322
end
300323

301324
end

public/js/sh_html.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/sh_javascript.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

views/onepage.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<% end %>
1818

1919
<% if !@no_js %>
20-
<%= 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') %>
20+
<%= 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') %>
2121
<script type="text/javascript">
2222
$(document).ready(function() {
2323
setupOnePage()

0 commit comments

Comments
 (0)