# File lib/pdfkit/pdfkit.rb, line 58 def to_pdf(path=nil) append_stylesheets args = command(path) invoke = args.join(' ') result = IO.popen(invoke, "wb+") do |pdf| pdf.puts(@source.to_s) if @source.html? pdf.close_write pdf.gets(nil) end result = File.read(path) if path raise "command failed: #{invoke}" if result.to_s.strip.empty? return result end