From 9964d7dc247b7b77f3c9cf3805dc612e49c53a16 Mon Sep 17 00:00:00 2001 From: sergey Date: Thu, 27 Apr 2023 17:09:43 +0300 Subject: [PATCH 1/2] MB-28756 Princely::Pdf: add pdf_from_list_to_file to generate from source file list --- lib/princely/pdf.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/princely/pdf.rb b/lib/princely/pdf.rb index 3091760..a4e02cc 100644 --- a/lib/princely/pdf.rb +++ b/lib/princely/pdf.rb @@ -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) @@ -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 From 749ac06afef0cbdf48442d6d7cf69ded3bed505a Mon Sep 17 00:00:00 2001 From: Rostyslav Date: Thu, 9 Oct 2025 16:28:34 +0300 Subject: [PATCH 2/2] Fix command to align with new version --- lib/princely/pdf.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/princely/pdf.rb b/lib/princely/pdf.rb index a4e02cc..4519684 100644 --- a/lib/princely/pdf.rb +++ b/lib/princely/pdf.rb @@ -124,9 +124,10 @@ def initialize_pdf_from_file_list(input_file, output_file, 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 << " --silent -o #{output_file}" path << " >> '#{log_file}' 2>> '#{log_file}'" if options[:output_to_log_file] log_command path if options[:log_command]