WkHtml
Ruby bindings for wkhtmltox (wkhtmltopdf). This gem should be considered experimental (see Todo).
Installation
Add this line to your application's Gemfile:
gem 'wkhtml'
And then execute:
$ bundle
Or install it yourself as:
$ gem install wkhtml
And if it can't find wkhtmltox/wkhtmltopdf, you can supply --with-wkhtmltox-dir
, --with-wkhtmltox-include
, or --with-wkhtmltox-lib
for location variations.
To use a windowing system for rendering, can be enabled with option --enable-use-graphics
. For more information, see GUIEnabled
portion of Qt QApplication.
Usage
#PDF
WkHtml::Converter.new('http://example.com/').to_pdf()
#JPEG
WkHtml::Converter.new('http://example.com/').to_jpg()
#PNG
WkHtml::Converter.new('http://example.com/').to_png()
#SVG
WkHtml::Converter.new('http://example.com/').to_svg()
#File
WkHtml::Converter.new('http://example.com/').to_file('/path', :pdf)
The #new
will take either a URI
, HTML content, or a File
.
Secondary argument takes a Hash
of options, a list of these options can be found here.
WkHtml::Converter.new('http://', {:useCompression => false})