Method: Html2Pdf::Utils.to_pdf
- Defined in:
- lib/html2pdf/utils.rb
.to_pdf(filename) ⇒ Object
Convert ‘*.xhtml’ or ‘*.html’ to pdf
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/html2pdf/utils.rb', line 22 def to_pdf(filename) fail "Invalid input file #{filename}" unless File.exist?(filename) command = [ 'wkhtmltopdf', '--margin-top 4', '--margin-bottom 4', '--margin-left 4', '--margin-right 4', '--header-center "[webpage] :: [page]/[topage]"', '--header-spacing 1', '--header-font-size 8', '--header-line', '--footer-spacing 1', '--footer-font-size 8', '--footer-line', "#{filename}", "#{filename}.pdf", '> /dev/null'] _stdin, _stderr, status = Open3.capture3(command.join(' ')) fail "Problem processing #{filename}" unless status.success? end |