Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom executable options #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion lib/princely/pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions spec/princely/pdf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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') }

Expand Down