Project

wkhtml

0.0
No commit activity in last 3 years
No release in over 3 years
Ruby bindings for wkhtmltopdf and wkhtmltoimage
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

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)