0.0
No commit activity in last 3 years
No release in over 3 years
Prawn itself provides only linear and radial gradients. This is the more advanced shadings that PDF spec defines.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 2.12

Runtime

< 1.1, >= 0.15.0
 Project Readme

Prawn Shadings

Build Status

This is a Prawn extension that implements advanced PDF shadings.

Specifically, it a bit refactors already implemented linear and radial gradients and adds a few more advanced ones.

Currently implemented shadings:

  • Axial Shadings (or linear gradients) (PDF Type 2 Shading)
  • Radial Shading (PDF Type 3 Shading)
  • Free-Form Gouraud-Shaded Triangle Meshes (PDF Type 4 Shading)
  • Lattice-Form Gouraud-Shaded Triangle Meshes (PDF Type 5 Shading)
  • Coons Patch Meshes (PDF Type 6 Shading)
  • Tensor-Product Patch Meshes (PDF Type 7 Shading)

API is simple but you need to know what data to supply. Please get familiar with Section 4.6.3 of PDF Reference.

A Word of Warning

Please note that this gem gives you ability use all these shadings in your generated PDF but gives no guarantee that PDF will be rendered correctly.

Just a few examples:

  • OS X Preview has problems with flags other than 0 in Type 4, 6 and 7 type shadings.
  • OS X Previews renders Type 7 shadings exactly the same as Type 6 shadings ignoring all 4 extra control points.
  • PDF.js can not render pretty much any of these.

Installation

gem install prawn-shadings

Usage

require 'prawn/shadings'

Testing

To run the tests:

$ rake

Contributing

  1. Fork it.
  2. Create a branch (git checkout -b my_shading)
  3. Commit your changes (git commit -am "Added Shading")
  4. Push to the branch (git push origin my_shading)
  5. Open a Pull Request