Html2Pdf
Convert multiple html or xhtml files to pdfs using the power of Ghostscript and Wkhtmltopdf.
Installation
Mandatory Requirement
This gem is built on top of my other gems
- agile_utils gem
- code_lister gem
Dependencies
- wkhtmltopdf (Linux/OSX)
- Ghostscript (Linux/OSX)
- OSX or Linux (no Windows sorry)
Usage
gem install html2pdf
For list of usage type
html2pdf
Which should give the following options
Usage:
html2pdf export [OPTIONS]
Options:
-b, [--base-dir=BASE_DIR] # Base directory
# Default: . (current directory)
-n, [--inc-words=one two three] # List of words to be included in the result
-x, [--exc-words=one two three] # List of words to be excluded from the result
-i, [--ignore-case], [--no-ignore-case] # Match case insensitively
# Default: true
-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.
├── demo1_xxx.rb.xhtml.pdf
├── demo2_xxx.rb.xhtml.pdf
└── sub_dir
├── demo3_xxx.rb.xhtml.pdf
└── demo4_xxx.rb.xhtml.pdf
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
Changelogs
0.0.3
- Update agile_utils to 0.0.8
- Update code_lister to 0.0.7
- Compress generated pdf files to one single tar.gzip file
- Fix bug in softwares_installed? method
- Remove the TODOs.md
0.0.2
Use agile_utils to 0.0.5
Fix minor error when using --version
0.0.1
- Initial release
Contributing
- Fork it ( http://github.com/
/code_exporter/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