html2pdf
Convert multiple html or xhtml files to pdfs using the power of wkhtmltopdf.
Note: starting from version 0.1.0 this gem will be release based on Semantic Versioning convention.
Installation
Mandatory Requirement
- wkhtmltopdf - please see wkhtmltopdf installation for detail
Dependencies
- wkhtmltopdf (Linux/OSX)
- OSX or Linux
Usage
gem install html2pdf
For list of usage type
html2pdf
Which should give the following output
Usage:
html2pdf
Options:
-b, [--base-dir=BASE_DIR] # Base directory
# Default: . (current directory)
-r, [--recursive], [--no-recursive] # Search for files recursively
# Default: true
-v, [--version], [--no-version] # Display version information
Example Usage
- Convert all
xhtmlandhtmlfromtest/fixtures/samplesdirectory recursivelyhtml2pdf -b test/fixtures/samples -rBefore the runtest/fixtures/samples/ ├── demo1_xxx.rb.xhtml ├── demo2_xxx.rb.xhtml └── sub_dir ├── demo3_xxx.rb.xhtml └── demo4_xxx.rb.xhtmlAfter the above command is executed:
You should get the output html2pdf-output.tar.gz
which contain the pdf version of the input files above.
e.g.
Usage Tips
This is my personal use case
Use vim_printer which export any source code to list of (x)html files in a single tar.gzipped file.
Use the output from vim_printer as input to this program so that you get the pdf version of it.
Then combine the generated pdf files using pdfs2pdf gem to produce one pdf file
Contributing
- Fork it ( http://github.com/agilecreativity/html2pdf/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request

