Module: Postdoc
- Defined in:
- lib/postdoc.rb,
lib/postdoc/job.rb,
lib/postdoc/batch.rb,
lib/postdoc/client.rb,
lib/postdoc/html_document.rb,
lib/postdoc/chrome_process.rb,
lib/postdoc/print_settings.rb
Defined Under Namespace
Classes: Batch, ChromeProcess, Client, HTMLDocument, Job, PrintSettings
Class Method Summary collapse
-
.batch(batch: Batch.new) {|batch| ... } ⇒ Object
result = Postdoc.batch do |batch| batch.add_document doc1 batch.add_document doc2, settings: with_footer end “‘.
- .render_from_string(content, **options) ⇒ Object
Class Method Details
.batch(batch: Batch.new) {|batch| ... } ⇒ Object
result = Postdoc.batch do |batch|
batch.add_document doc1
batch.add_document doc2, settings:
end “‘
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/postdoc.rb', line 41 def self.batch(batch: Batch.new) yield(batch) begin server = ChromeProcess.new batch.result(server.client) ensure if server.client.client.present? server.client.client.send_cmd 'Browser.close' end server.kill batch.cleanup end end |
.render_from_string(content, **options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/postdoc.rb', line 15 def self.render_from_string(content, **) print_settings = PrintSettings.new(**) server = ChromeProcess.new(**) html_file = HTMLDocument.new(content) server.client .print_pdf_from_html(html_file.path, settings: print_settings) ensure if server.client.client.present? server.client.client.send_cmd 'Browser.close' end server.kill html_file.cleanup end |