Class: HtmlsToPdf
- Inherits:
-
Object
- Object
- HtmlsToPdf
- Defined in:
- lib/htmls_to_pdf/htmls_to_pdf.rb
Overview
HtmlsToPdf.new takes a configuration hash and returns an object with a create_pdf() method Calling create_pdf() on the HtmlsToPdf object generates a PDF file configured according to the configuration hash settings
Usage: HtmlsToPdf.new(options_hash).create_pdf
Constant Summary collapse
- TMP_HTML_PREFIX =
'tmp_html_file_'
- TMP_PDF_PREFIX =
'tmp_pdf_file_'
Instance Attribute Summary collapse
-
#cssarray ⇒ Object
Returns the value of attribute cssarray.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#htmlarray ⇒ Object
Returns the value of attribute htmlarray.
-
#options ⇒ Object
Returns the value of attribute options.
-
#overwrite_existing_pdf ⇒ Object
Returns the value of attribute overwrite_existing_pdf.
-
#pdfarray ⇒ Object
Returns the value of attribute pdfarray.
-
#remove_css_files ⇒ Object
Returns the value of attribute remove_css_files.
-
#remove_html_files ⇒ Object
Returns the value of attribute remove_html_files.
-
#remove_temp_files ⇒ Object
Returns the value of attribute remove_temp_files.
-
#remove_tmp_pdf_files ⇒ Object
Returns the value of attribute remove_tmp_pdf_files.
-
#savedir ⇒ Object
Returns the value of attribute savedir.
-
#savename ⇒ Object
Returns the value of attribute savename.
-
#urls ⇒ Object
Returns the value of attribute urls.
Instance Method Summary collapse
- #create_pdf ⇒ Object
-
#initialize(config = {}) ⇒ HtmlsToPdf
constructor
A new instance of HtmlsToPdf.
Constructor Details
#initialize(config = {}) ⇒ HtmlsToPdf
Returns a new instance of HtmlsToPdf.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 22 def initialize(config = {}) defaults = { remove_css_files: true, remove_html_files: true, remove_tmp_pdf_files: true, overwrite_existing_pdf: false, savedir: "~", savename: 'htmls_to_pdf.pdf', debug: false } config = defaults.merge!(config) set_instance_vars(config) set_dir(@savedir) exit_if_pdf_exists unless @overwrite_existing_pdf end |
Instance Attribute Details
#cssarray ⇒ Object
Returns the value of attribute cssarray.
17 18 19 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 17 def cssarray @cssarray end |
#debug ⇒ Object
Returns the value of attribute debug.
17 18 19 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 17 def debug @debug end |
#htmlarray ⇒ Object
Returns the value of attribute htmlarray.
17 18 19 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 17 def htmlarray @htmlarray end |
#options ⇒ Object
Returns the value of attribute options.
17 18 19 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 17 def @options end |
#overwrite_existing_pdf ⇒ Object
Returns the value of attribute overwrite_existing_pdf.
17 18 19 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 17 def overwrite_existing_pdf @overwrite_existing_pdf end |
#pdfarray ⇒ Object
Returns the value of attribute pdfarray.
17 18 19 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 17 def pdfarray @pdfarray end |
#remove_css_files ⇒ Object
Returns the value of attribute remove_css_files.
17 18 19 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 17 def remove_css_files @remove_css_files end |
#remove_html_files ⇒ Object
Returns the value of attribute remove_html_files.
17 18 19 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 17 def remove_html_files @remove_html_files end |
#remove_temp_files ⇒ Object
Returns the value of attribute remove_temp_files.
17 18 19 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 17 def remove_temp_files @remove_temp_files end |
#remove_tmp_pdf_files ⇒ Object
Returns the value of attribute remove_tmp_pdf_files.
17 18 19 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 17 def remove_tmp_pdf_files @remove_tmp_pdf_files end |
#savedir ⇒ Object
Returns the value of attribute savedir.
17 18 19 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 17 def savedir @savedir end |
#savename ⇒ Object
Returns the value of attribute savename.
17 18 19 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 17 def savename @savename end |
#urls ⇒ Object
Returns the value of attribute urls.
17 18 19 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 17 def urls @urls end |
Instance Method Details
#create_pdf ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/htmls_to_pdf/htmls_to_pdf.rb', line 41 def create_pdf clean_temp_files get_temp_files # update_asset_urls generate_pdfs join_pdfs clean_temp_files end |