module Postdoc
Public Class Methods
batch(batch: Batch.new) { |batch| ... }
click to toggle source
result = Postdoc.batch
do |batch|
batch.add_document doc1 batch.add_document doc2, settings: with_footer
end “`
# 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)
click to toggle source
# File lib/postdoc.rb, line 15 def self.render_from_string(content, **options) print_settings = PrintSettings.new(**options) server = ChromeProcess.new(**options) 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