diff --git a/lib/princely/pdf.rb b/lib/princely/pdf.rb index 76b7b2a..ac3fbe5 100644 --- a/lib/princely/pdf.rb +++ b/lib/princely/pdf.rb @@ -106,8 +106,11 @@ def initialize_pdf_from_string(string, output_file, options = {}) log_command path if options[:log_command] + # Make sure the log file exists before the pipe creation. + FileUtils.touch log_file + # Actually call the prince command, and pass the entire data stream back. - pdf = IO.popen(path, "w+") + pdf = IO.popen(path, "w+", err: log_file.to_s) pdf.puts string pdf end diff --git a/spec/princely/pdf_spec.rb b/spec/princely/pdf_spec.rb index ef761c8..74f517e 100644 --- a/spec/princely/pdf_spec.rb +++ b/spec/princely/pdf_spec.rb @@ -8,7 +8,7 @@ end it "generates a PDF from HTML" do - pdf = Princely::Pdf.new.pdf_from_string html_doc + pdf = Princely::Pdf.new(log_file: "/tmp/test_log").pdf_from_string html_doc expect(pdf).to start_with("%PDF-1.4") expect(pdf.rstrip).to end_with("%%EOF") pdf.length > 100