https://github.com/neume/sugpoko
A prawnpdf wrapper to easily manage pdf components
https://github.com/neume/sugpoko
pdf prawn prawn-pdf prawn-rails ruby
Last synced: 2 months ago
JSON representation
A prawnpdf wrapper to easily manage pdf components
- Host: GitHub
- URL: https://github.com/neume/sugpoko
- Owner: neume
- Created: 2019-08-21T14:07:21.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-29T18:35:21.000Z (over 5 years ago)
- Last Synced: 2024-10-18T15:17:19.558Z (8 months ago)
- Topics: pdf, prawn, prawn-pdf, prawn-rails, ruby
- Language: Ruby
- Size: 12.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sugpoko
Modularize your pdf code with this gem
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'prawn'
gem 'sugpoko'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install sugpoko
## Usage
Create a class that inherits `Sugpoko::Base`. This class is the main pdf component
where the pdf generation is triggered. It includes `Prawn::View` module.``` ruby
class PdfDocument < Sugpoko::Base
def generate
pdf.text 'Hello World'
end
endPdfDocument.new.generate
# Hello world
```A component can also be created using `Sugpoko::Component`
``` ruby
class Header < Sugpoko::Component
def generate
pdf.text 'This is a header'
end
end
```To add `Header` on our previous base document, use `draw` method. It accepts a
class that inherits from either `Sugpoko::Base` or `Sugpoko::Component`.
``` ruby
class PdfDocument < Sugpoko::Base
def generate
draw Header
pdf.text 'Hello World'
draw ...
end
endPdfDocument.new.generate
# This is a Header
# Hello World
````Sugpoko::Component` can also use `draw` method
Bug reports and pull requests are welcome on GitHub at https://github.com/neume/sugpoko.