Class: PDFService::PhantomJSRenderer
- Inherits:
-
Object
- Object
- PDFService::PhantomJSRenderer
- Defined in:
- lib/pdf_service/phantom_js_renderer.rb
Constant Summary collapse
- RASTERIZE_SCRIPT_PATH =
Pathname(__FILE__).dirname.join('phantomjs_rasterize.js').to_s.freeze
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(script: RASTERIZE_SCRIPT_PATH, logger: NullLogger.new, binary: 'phantomjs') ⇒ PhantomJSRenderer
constructor
A new instance of PhantomJSRenderer.
- #rasterize(url, output, format: 'A4') ⇒ Object
Constructor Details
#initialize(script: RASTERIZE_SCRIPT_PATH, logger: NullLogger.new, binary: 'phantomjs') ⇒ PhantomJSRenderer
Returns a new instance of PhantomJSRenderer.
6 7 8 9 10 11 |
# File 'lib/pdf_service/phantom_js_renderer.rb', line 6 def initialize(script: RASTERIZE_SCRIPT_PATH, logger: NullLogger.new, binary: 'phantomjs') @script = script.freeze @logger = logger @binary = binary.freeze Kernel.warn("Warning! PhantomJS is not available in PATH #{@binary}") if `which #{binary}`.strip.empty? end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
12 13 14 |
# File 'lib/pdf_service/phantom_js_renderer.rb', line 12 def logger @logger end |
Instance Method Details
#rasterize(url, output, format: 'A4') ⇒ Object
14 15 16 17 |
# File 'lib/pdf_service/phantom_js_renderer.rb', line 14 def rasterize(url, output, format: 'A4') = [url, output, format] phantomjs(@script, url, ) end |