lib/pdfgen.rb in pdfgen-0.1.0 vs lib/pdfgen.rb in pdfgen-0.2.0
- old
+ new
@@ -11,10 +11,11 @@
class Pdfgen
def initialize(html)
@html = html
@viewport_options = nil
@emulate_media = nil
+ @launch_options = nil
end
def set_viewport(viewport_options)
@viewport_options = viewport_options
self
@@ -23,13 +24,19 @@
def emulate_media(media_type)
@emulate_media = media_type
self
end
+ def launch_options(launch_options)
+ @launch_options = launch_options
+ self
+ end
+
def to_pdf(opts = {})
stdin_options = { pdf_options: opts, current_path: Dir.pwd }
stdin_options = stdin_options.merge(viewport_options: @viewport_options) if @viewport_options
stdin_options = stdin_options.merge(emulate_media: @emulate_media) if @emulate_media
+ stdin_options = stdin_options.merge(launch_options: @launch_options) if @launch_options
file = Tempfile.new('input_html')
file.write(@html)
file.close
pdf_output, status = Open3.capture2(MAKE_PDF_COMMAND, file.path, stdin_data: stdin_options.to_json)
file.unlink
\ No newline at end of file