Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 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,23 @@ 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.sub!(/--input=html\s*/, '')
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