Class: Dhalang::PDF
- Inherits:
-
Object
- Object
- Dhalang::PDF
- Defined in:
- lib/PDF.rb
Overview
Allows consumers of this library to create PDFs with Puppeteer.
Class Method Summary collapse
-
.get_from_html(html, options = {}) ⇒ String
Captures the full HTML as PDF.
-
.get_from_url(url, options = {}) ⇒ String
Captures the full webpage under the given url as PDF.
Class Method Details
.get_from_html(html, options = {}) ⇒ String
Captures the full HTML as PDF. Useful when creating dynamic content, for example invoices.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/PDF.rb', line 25 def self.get_from_html(html, = {}) html_file = FileUtils.create_temp_file("html", html) url = "file://" + html_file.path begin binary_pdf_content = get(url, ) ensure FileUtils.delete(html_file) end return binary_pdf_content end |