Class: Kamisaku::ChromeRunner
- Inherits:
-
Object
- Object
- Kamisaku::ChromeRunner
- Defined in:
- lib/kamisaku/chrome_runner.rb
Instance Method Summary collapse
- #html_to_pdf(html_path, pdf_path, pdf_header_footer: false) ⇒ Object
-
#initialize(sandbox: false, headless: true, gpu: false) ⇒ ChromeRunner
constructor
A new instance of ChromeRunner.
Constructor Details
#initialize(sandbox: false, headless: true, gpu: false) ⇒ ChromeRunner
Returns a new instance of ChromeRunner.
3 4 5 6 7 8 |
# File 'lib/kamisaku/chrome_runner.rb', line 3 def initialize(sandbox: false, headless: true, gpu: false) @base_args = ["--run-all-compositor-stages-before-draw"] @base_args << "--no-sandbox" unless sandbox @base_args << "--headless" if headless @base_args << "--disable-gpu" unless gpu end |
Instance Method Details
#html_to_pdf(html_path, pdf_path, pdf_header_footer: false) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/kamisaku/chrome_runner.rb', line 10 def html_to_pdf(html_path, pdf_path, pdf_header_footer: false) args = [*@base_args] args << "--no-pdf-header-footer" unless args << "--print-to-pdf=#{pdf_path}" args << html_path system("google-chrome", *args) end |