Project

sugpoko

0.0
No commit activity in last 3 years
No release in over 3 years
Modularize your prawnpdf code
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
>= 0
~> 10.0
~> 3.0
 Project Readme

Sugpoko

Modularize your pdf code with this gem

Installation

Add this line to your application's Gemfile:

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.

class PdfDocument < Sugpoko::Base
  def generate
    pdf.text 'Hello World'
  end
end

PdfDocument.new.generate
# Hello world

A component can also be created using Sugpoko::Component

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.

class PdfDocument < Sugpoko::Base
  def generate
    draw Header
    pdf.text 'Hello World'
    draw ...
  end
end

PdfDocument.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.