Skip to content

Commit

Permalink
MB-28756 Princely::Pdf: add pdf_from_list_to_file to generate from so…
Browse files Browse the repository at this point in the history
…urce file list
  • Loading branch information
K-S-A committed Apr 27, 2023
1 parent 565f500 commit 9964d7d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/princely/pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ def pdf_from_string_to_file(string, output_file)
end
end

def pdf_from_list_to_file(input_file, output_file)
with_timeout do
pdf = initialize_pdf_from_file_list(input_file, output_file)
pdf.close
end
end

protected

def with_timeout(&block)
Expand Down Expand Up @@ -112,6 +119,22 @@ def initialize_pdf_from_string(string, output_file, options = {})
pdf
end

def initialize_pdf_from_file_list(input_file, output_file, options = {})
options = {:log_command => true, :output_to_log_file => true}.merge(options)
path = exe_path
# Don't spew errors to the standard out...and set up to take IO
# as input and output
path << " --input-list=#{input_file}"
path << " --media=#{media}" if media
path << " --silent - -o #{output_file}"
path << " >> '#{log_file}' 2>> '#{log_file}'" if options[:output_to_log_file]

log_command path if options[:log_command]

# Actually call the prince command, and pass the entire data stream back.
IO.popen(path, "w+")
end

def log_command(path)
logger.info "\n\nPRINCE XML PDF COMMAND"
logger.info path
Expand Down

0 comments on commit 9964d7d

Please sign in to comment.