Skip to content
/ sugpoko Public

A prawnpdf wrapper to easily manage pdf components

Notifications You must be signed in to change notification settings

neume/sugpoko

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A prawnpdf wrapper to easily manage pdf components

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published