Elegant
Elegant provides a nice layout for PDF reports generated in Ruby.
The source code is available on GitHub and the documentation on RubyDoc.
Elegant is a library built on top of Prawn to generate PDF files in Ruby.
Whereas Prawn creates PDF pages that are completely blank (letting users customize them at will), Elegant comes with a nice layout that makes each page look… elegant! 😉
How to use
If you have never used Prawn to generate PDF files, you should first read its manual.
Using Elegant is as simple as replacing any instance of Prawn::Document
with Elegant::Document
:
# with Prawn
Prawn::Document.new do
text 'Hello, World!'
end
# with Elegant
Elegant::Document.new do
text 'Hello, World!'
end
# with Elegant and extra options
header = {text: 'A report', logo: {url: 'http://lorempixel.com/500/500'}}
footer = {text: 'A link', url: 'http://www.example.com'}
Elegant::Document.new(header: header, footer: footer) do
title 'Welcome'
text 'Hello, world!'
end
Elegant::Document
accepts some options [... TODO ...]
How to install
Elegant requires Ruby 2.1 or higher.
To include in your project, add gem 'elegant', ~> '1.0'
to the Gemfile
file of your Ruby project.
How to generate the manual
rake manual
How to contribute
If you’ve made it this far in the README… thanks! ✌️ Feel free to try it the gem, explore the code, and send issues or pull requests.
All pull requests will have to make Travis and Code Climate happy in order to be accepted. 😙
You can also run the tests locally with bundle exec rspec
.
Happy hacking!