Module: Ferrum::Page::Screenshot
- Included in:
- Ferrum::Page
- Defined in:
- lib/ferrum/page/screenshot.rb
Constant Summary collapse
- DEFAULT_PDF_OPTIONS =
{ landscape: false, paper_width: 8.5, paper_height: 11, scale: 1.0 }.freeze
- PAPEP_FORMATS =
{ letter: { width: 8.50, height: 11.00 }, legal: { width: 8.50, height: 14.00 }, tabloid: { width: 11.00, height: 17.00 }, ledger: { width: 17.00, height: 11.00 }, A0: { width: 33.10, height: 46.80 }, A1: { width: 23.40, height: 33.10 }, A2: { width: 16.54, height: 23.40 }, A3: { width: 11.70, height: 16.54 }, A4: { width: 8.27, height: 11.70 }, A5: { width: 5.83, height: 8.27 }, A6: { width: 4.13, height: 5.83 }, }.freeze
Instance Method Summary collapse
Instance Method Details
#document_size ⇒ Object
49 50 51 52 53 54 |
# File 'lib/ferrum/page/screenshot.rb', line 49 def document_size evaluate <<~JS [document.documentElement.scrollWidth, document.documentElement.scrollHeight] JS end |
#pdf(**opts) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/ferrum/page/screenshot.rb', line 35 def pdf(**opts) path, encoding = (**opts) = (**opts) data = command("Page.printToPDF", **).fetch("data") return data if encoding == :base64 save_file(path, data) end |
#screenshot(**opts) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/ferrum/page/screenshot.rb', line 27 def screenshot(**opts) path, encoding = (**opts) = (path, **opts) data = capture_screenshot(, opts[:full]) return data if encoding == :base64 save_file(path, data) end |
#viewport_size ⇒ Object
43 44 45 46 47 |
# File 'lib/ferrum/page/screenshot.rb', line 43 def evaluate <<~JS [window.innerWidth, window.innerHeight] JS end |