Class: Kamisaku::ChromeRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/kamisaku/chrome_runner.rb

Instance Method Summary collapse

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 pdf_header_footer
  args << "--print-to-pdf=#{pdf_path}"
  args << html_path
  system("google-chrome", *args)
end