prawn_plus

A Rails renderer for Prawn PDFs.

https://github.com/bkuhlmann/prawn_plus

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.8%) to scientific vocabulary

Keywords

pdf prawn template-engine
Last synced: 6 months ago · JSON representation ·

Repository

A Rails renderer for Prawn PDFs.

Basic Info
Statistics
  • Stars: 31
  • Watchers: 3
  • Forks: 3
  • Open Issues: 0
  • Releases: 0
Topics
pdf prawn template-engine
Created over 13 years ago · Last pushed 9 months ago
Metadata Files
Readme Funding License Citation

README.adoc

:toc: macro
:toclevels: 5
:figure-caption!:

= Prawn+

‼️ *This gem is deprecated and will be fully destroyed on 2026-01-15. There is no replacement. Please update accordingly.* ‼️

Prawn+ is a lightweight Rails Engine that wraps the link:https://github.com/prawnpdf/prawn[Prawn]
PDF generator in order to render PDFs within Rails views. This allows you to build view templates
which render PDFs using the Prawn syntax.

toc::[]

== Features

* Loads the https://github.com/prawnpdf/prawn[Prawn] gem by default (no Gemfile entry necessary).
* Registers PDF as a MIME type.
* Registers a template handler for rendering "`.prawn`" template view files.

== Requirements

. https://www.ruby-lang.org[Ruby]
. https://rubyonrails.org[Ruby on Rails]
. https://github.com/prawnpdf/prawn[Prawn]

== Setup

To install _with_ security, run:

[source,bash]
----
# 💡 Skip this line if you already have the public certificate installed.
gem cert --add <(curl --compressed --location https://alchemists.io/gems.pem)
gem install prawn_plus --trust-policy HighSecurity
----

To install _without_ security, run:

[source,bash]
----
gem install prawn_plus
----

You can also add the gem directly to your project:

[source,bash]
----
bundle add prawn_plus
----

Once the gem is installed, you only need to require it:

[source,ruby]
----
require "prawn_plus"
----

== Usage

=== Views

Within your views you can craft Prawn templates using Ruby code. For example, assuming there are
document resources, then the following structure might exist:

....
/views/documents/show.html.slim
/views/documents/show.pdf.prawn
....

The `show.html.slim` could have a link to the PDF download. Example:

....
= link_to "PDF Download", action: "show", id: @document.id, format: "pdf"
....

The `show.pdf.prawn` file would contain the Prawn syntax for crafting the PDF. A simple example
might look like this:

[source,ruby]
----
pdf.text "Hello, I'm a PDF!"
----

...which would render the following output:

image::https://alchemists.io/images/projects/prawn_plus/screenshots/basic.png[Basic Example]

You could also render a more complex PDF with tabular information, for example:

[source,ruby]
----
pdf.text "Metals"
pdf.move_down 10
pdf.font_size = 10

data = [
  ["Name", "Atomic Number", "Price"],
  ["Mercury", "80", number_to_currency(10)],
  ["Platinum", "78", number_to_currency(25)],
  ["Titanium", "22", number_to_currency(50)]
]

pdf.table data, header: true, column_widths: [100, 50, 50], row_colors: ["FFFFFF", "E5ECF9"] do
  columns(0).align = :left
  columns(1..2).align = :right
  row(0).text_color = "FFFFFF"
  row(0).background_color = "000000"
  row(0).columns(0..2).font_style = :bold
  row(0).columns(0..2).align = :center
end
----

...which would render the following output:

image::https://alchemists.io/images/projects/prawn_plus/screenshots/complex.png[Complex Example]

_NOTE: The `pdf` object must always be referenced when making using of the Prawn syntax - it is
initialized for you as a Prawn::Document instance._

=== Controllers

Within your controller, only the `respond_to` method is required. Example:

[source,ruby]
----
class DocumentsController < ApplicationController
  respond_to :pdf

  def show
  end
end
----

That’s it!

== Development

To contribute, run:

[source,bash]
----
git clone https://github.com/bkuhlmann/prawn_plus
cd prawn_plus
bin/setup
----

You can also use the IRB console for direct access to all objects:

[source,bash]
----
bin/console
----

== Tests

To test, run:

[source,bash]
----
bin/rake
----

== link:https://alchemists.io/policies/license[License]

== link:https://alchemists.io/policies/security[Security]

== link:https://alchemists.io/policies/code_of_conduct[Code of Conduct]

== link:https://alchemists.io/policies/contributions[Contributions]

== link:https://alchemists.io/policies/developer_certificate_of_origin[Developer Certificate of Origin]

== link:https://alchemists.io/projects/prawn_plus/versions[Versions]

== link:https://alchemists.io/community[Community]

== Credits

* Built with link:https://alchemists.io/projects/gemsmith[Gemsmith].
* Engineered by link:https://alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].

Owner

  • Name: Brooke Kuhlmann
  • Login: bkuhlmann
  • Kind: user
  • Location: Boulder, CO USA
  • Company: Alchemists

Quality over quantity.

Citation (CITATION.cff)

cff-version: 1.2.0
message: Please use the following metadata when citing this project in your work.
title: Prawn+
abstract: A Rails renderer for Prawn PDFs.
version: 16.2.1
license: Hippocratic-2.1
date-released: 2025-06-05
authors:
  - family-names: Kuhlmann
    given-names: Brooke
    affiliation: Alchemists
    orcid: https://orcid.org/0000-0002-5810-6268
keywords:
 - ruby
 - engine
 - PDF
repository-code: https://github.com/bkuhlmann/prawn_plus
repository-artifact: https://rubygems.org/gems/prawn_plus
url: https://alchemists.io/projects/prawn_plus

GitHub Events

Total
  • Delete event: 142
  • Push event: 30
  • Create event: 10
Last Year
  • Delete event: 142
  • Push event: 30
  • Create event: 10

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 708
  • Total Committers: 3
  • Avg Commits per committer: 236.0
  • Development Distribution Score (DDS): 0.169
Past Year
  • Commits: 53
  • Committers: 1
  • Avg Commits per committer: 53.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Brooke Kuhlmann b****e@a****o 588
Brooke Kuhlmann b****e@r****m 119
Alexander Ross r****s@s****e 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 2
  • Total pull requests: 1
  • Average time to close issues: about 6 hours
  • Average time to close pull requests: 9 days
  • Total issue authors: 2
  • Total pull request authors: 1
  • Average comments per issue: 2.0
  • Average comments per pull request: 3.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • gr8bit (1)
  • beemwe (1)
Pull Request Authors
  • alex-ross (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

Gemfile rubygems
  • amazing_print ~> 1.4 development
  • caliber ~> 0.8 development
  • capybara ~> 3.1 development
  • debug ~> 1.5 development
  • git-lint ~> 4.0 development
  • guard-rspec ~> 4.7 development
  • pg ~> 1.2 development
  • rake ~> 13.0 development
  • reek ~> 6.1 development
  • rspec-rails ~> 5.0 development
  • simplecov ~> 0.21 development
prawn_plus.gemspec rubygems
  • prawn ~> 2.4
  • prawn-table ~> 0.2
  • rails ~> 7.0
  • refinements ~> 9.4