Class: MakePDF::Chrome
- Inherits:
-
MakePDF::CommandBased::Writer
- Object
- PDFWriter
- MakePDF::CommandBased::Writer
- MakePDF::Chrome
- Defined in:
- lib/make_pdf/chrome.rb
Constant Summary collapse
- COMMAND =
'chrome-headless-render-pdf'- DEFAULT_OPTIONS =
options from 'chrome-headless-render-pdf --help'
{ # options from 'chrome-headless-render-pdf --help' "chrome-binary": nil, "chrome-option": nil, "remote-host": nil, "remote-port": nil, "no-margins": true, "include-background": true, "landscape": false, "window-size": nil, "paper-width": nil, "paper-height": nil, "page-ranges": nil, "scale": nil, "display-header-footer": false, "header-template": nil, "footer": nil, "js-time-budget": nil, "animation-time-budget": nil, }
Instance Attribute Summary
Attributes inherited from MakePDF::CommandBased::Writer
Attributes included from MakePDF::CommandBased::Arguments
Attributes inherited from PDFWriter
#logger, #output_dir, #source_url
Instance Method Summary collapse
-
#initialize(**options) ⇒ Chrome
constructor
A new instance of Chrome.
- #map_option_key(key, value) ⇒ Object
Methods inherited from MakePDF::CommandBased::Writer
Methods included from MakePDF::CommandBased::Arguments
Methods inherited from PDFWriter
#make_output_filename, #make_pdf_filename, #make_relative_file, #make_source_url, #process
Methods included from PathManip
Constructor Details
#initialize(**options) ⇒ Chrome
Returns a new instance of Chrome.
26 27 28 |
# File 'lib/make_pdf/chrome.rb', line 26 def initialize(**) super(command: COMMAND, **.merge(DEFAULT_OPTIONS)) end |
Instance Method Details
#map_option_key(key, value) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/make_pdf/chrome.rb', line 30 def map_option_key(key, value) case key when 'source-url' [ '--url', value ] when 'output-filename' [ '--pdf', value ] when DEFAULT_OPTIONS.keys.method(:include?) case value when false, nil? [] when true, "" [ "--#{key.to_s}" ] else [ "--#{key.to_s}", value ] end else [] end end |