forked from reefab/ResumeMan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakepdf.rb
32 lines (26 loc) · 1.09 KB
/
makepdf.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module PdfMaker
class << self
def registered(app)
app.after_build do |builder|
begin
require 'pdfkit'
kit = PDFKit.new(File.new('build/index.html'),
:margin_top => 10,
:margin_bottom => 0,
:margin_left => 0,
:margin_right => 0,
# :disable_smart_shrinking => true,
:print_media_type => true,
:dpi => 96)
file = kit.to_file('build/resume.pdf')
rescue Exception =>e
builder.say_status "PDF Maker", "Error: #{e.message}", Thor::Shell::Color::RED
raise
end
builder.say_status "PDF Maker", "PDF file available at build/resume.pdf"
end
end
alias :included :registered
end
end
::Middleman::Extensions.register(:pdfmaker, PdfMaker)