diff --git a/README.md b/README.md index 0364b47..bc65cca 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ The defaults for the render options are as follows: server_flag: true javascript_flag: false timeout: none + exe_options: none ## Contributors diff --git a/lib/princely/pdf.rb b/lib/princely/pdf.rb index 76b7b2a..e237bc3 100644 --- a/lib/princely/pdf.rb +++ b/lib/princely/pdf.rb @@ -14,7 +14,8 @@ def initialize(options={}) :logger => nil, :server_flag => true, :media => nil, - :javascript_flag => false + :javascript_flag => false, + :exe_options => [] }.merge(options) @executable = options[:path] ? Princely::Executable.new(options[:path]) : options[:executable] @style_sheets = '' @@ -24,6 +25,7 @@ def initialize(options={}) @media = options[:media] @javascript_flag = options[:javascript_flag] @timeout = options[:timeout] + @custom_exe_options = options[:exe_options] end # Returns the instance logger or Princely default logger @@ -58,6 +60,7 @@ def executable_options options << "--media=#{media}" if media options << "--javascript" if @javascript_flag options << @style_sheets + options += @custom_exe_options options end diff --git a/spec/princely/pdf_spec.rb b/spec/princely/pdf_spec.rb index ef761c8..8103dd3 100644 --- a/spec/princely/pdf_spec.rb +++ b/spec/princely/pdf_spec.rb @@ -51,6 +51,17 @@ end end + describe "exe_options with array" do + before(:each) do + allow(prince).to receive(:log_file).and_return('/tmp/test_log') + end + + let(:prince) { Princely::Pdf.new(:exe_options => ['--xml-external-entities']) } + it 'adds them to the other options' do + expect(prince.executable_options).to include('--xml-external-entities') + end + end + describe "exe_path" do let(:prince) { Princely::Pdf.new(:path => '/tmp/fake') }