Skip to content

Commit

Permalink
Silence Prince message fin|success
Browse files Browse the repository at this point in the history
Changes how the Prince command is executed and stdout is capture in
order to hide the message `fin|success`.
  • Loading branch information
repinel committed Nov 22, 2019
1 parent 559f374 commit 6ba86dd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/princely/pdf.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'open3'
require 'timeout'

module Princely
Expand Down Expand Up @@ -69,9 +70,8 @@ def executable_options
def pdf_from_string(string, output_file = '-')
with_timeout do
pdf = initialize_pdf_from_string(string, output_file, {:output_to_log_file => false})
pdf.close_write
result = pdf.gets(nil)
pdf.close_read
pdf.close
result.force_encoding('BINARY') if RUBY_VERSION >= "1.9"

result
Expand Down Expand Up @@ -107,9 +107,10 @@ def initialize_pdf_from_string(string, output_file, options = {})
log_command path if options[:log_command]

# Actually call the prince command, and pass the entire data stream back.
pdf = IO.popen(path, "w+")
pdf.puts string
pdf
stdin, stdout = Open3.popen3(path)
stdin.puts string
stdin.close
stdout
end

def log_command(path)
Expand Down

0 comments on commit 6ba86dd

Please sign in to comment.