Skip to content

carsonreinke/wkhtml

Repository files navigation

WkHtml

Build Status

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})

Todo

  • Memory leak with any image conversion 😞 (see)
  • Due to wkhtmltopdf C api limitation, seg fault when try to use library from fork 😞
  • Due to wkhtmltopdf C api limitation, must be used within main Ruby VM thread 😞
  • Some settings for image generation just do not work 😭 (see)

About

Ruby bindings for wkhtmltox (wkhtmltopdf)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages