Library / SDK
prawnpdf/prawn avatar
prawnpdf/prawn

Prawn: a pure Ruby PDF generator for programmatic documents

Fast, Nimble PDF Writer for Ruby

4,822 stars696 forksRubyNOASSERTION

At a glance

What is it?
Prawn builds PDFs from Ruby code instead of from HTML, and the README is explicit that it never intends to be an HTML to PDF converter. Here is what it does well, where it stops, and what to check before adding it to a Gemfile.
Who is it for?
Adopt Prawn when the document is generated from data you already hold in Ruby and you want control over placement, fonts and page furniture rather than a browser rendering pipeline. Do not adopt it if your source of truth is an HTML template or a web page, because the README states it is not and will never be an HTML to PDF generator; Ferrum is the project's own pointer for that job.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository last received commits 165 days ago.
What is it written in?
Mainly Ruby, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 27, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What Prawn is for, and the case it refuses

Prawn is a pure Ruby library that writes PDF files. The README frames it as a flexible document generation system, and it draws a hard boundary around itself in the same paragraph: it is not a reporting tool or a publishing toolchain, though the README notes it could be used to build those things. The audience is therefore a Ruby developer who has data in memory or in a database and wants a PDF whose geometry they control directly.

The refusal is the more interesting part. The README states plainly that Prawn is not, and will never be, an HTML to PDF generator, and points readers at Ferrum for that need. It acknowledges basic inline styling support but calls it a very small subset of functionality, unsuitable for rich HTML documents. That is an unusually direct statement of scope for a library README, and it saves a category of user from a wrong turn. If your team's design workflow produces HTML and CSS, Prawn is the wrong tool, and the project says so before you install it.

How a Prawn document is actually built

The unit of work is a block passed to Prawn::Document.generate. Inside that block you call drawing and text methods against an implicit cursor and bounding box, and the library translates those calls into PDF content streams. The README's feature list maps onto that model: vector drawing for lines, polygons, curves and ellipses; flowing text with limited inline formatting; a simple grid system for layout; PNG and JPG embedding with scaling; and repeatable content for headers, footers and page numbers.

Two layers sit underneath. The first is fonts: Prawn supports PDF builtin fonts and embedded TrueType fonts, with UTF-8 support, right-to-left text rendering and fallback font support for internationalization. The second is the PDF object tree itself. The README describes low level features that let users create custom extensions by dropping down to that layer, and it flags the requirement honestly: this is mostly useful to people who know the PDF specification. There is also a bench/ directory in the repository, which indicates the maintainers keep performance measurements in tree, though the README makes no numeric claim about them.

Installing Prawn and producing a first PDF

Prawn ships as a RubyGem. The README gives one installation command, and it is the ordinary gem install path rather than a bundler-specific one.

bash
gem install prawn

The README also notes you can install from git, where the master branch holds the latest developments. It warns that master is kept in working order but may carry rough edges and fresh bugs alongside bugfixes.

The first real use is the Hello World example from the README. It requires the library and generates a file through the block form.

ruby
require "prawn"

Prawn::Document.generate("hello.pdf") do
  text "Hello World!"
end

If that code runs and produces a working PDF file, the README treats the installation as successful. From there, the manual is the next stop. The README describes the manual as a series of examples rather than a reference, and says a generated version of the latest released Prawn is available on the Prawn website. The examples live in the manual directory of the repository. To build the manual yourself, the README lists cloning the repository, running gem install -g, then running rake manual, which writes _manual.pdf in the project root. Note that the README's numbered list skips from 1 to 3, which is a small editing slip rather than a missing step.

Versioning promises you should not assume

Prawn's release policy is the section most likely to surprise a team that expects Semantic Versioning. The README says the project does not formally follow SemVer, because it ships a number of experimental APIs whose stability it does not promise. The stable portion of the API is described as following Semantic Versioning, which leaves the boundary between stable and experimental as something the reader has to establish from the API docs.

There is a second caveat with sharper practical consequences: bug fixes can change behaviour, and the project does not consider that a breaking change for versioning purposes. The README's instruction is to read the release notes in CHANGELOG.md each time a release is cut and to lock your gems accordingly. That is a direct statement that a patch-level bump may alter output. For a library whose output is a document, an altered output can mean a shifted layout or a changed page count, so the lockfile is doing real work here rather than being routine hygiene.

The release cadence reinforces this. The most recent release listed is 2.3.0 from 2020-08-01, preceded by 2.2.0 from 2017-03-11 and 2.1.0 from 2016-03-01. The repository's last push was on 2026-04-18, so commits continue well past the last tagged release. Anyone tracking the gem is tracking a version line that moves slowly, while the master branch moves separately.

Where the documentation runs out

The README is candid that the manual is not exhaustive and directs readers to the API docs for complete information. That is a reasonable split for a library with this many entry points, but it means the manual will not answer every layout question, and the API docs are the authority on method behaviour.

The support channel is GitHub Discussions rather than an issue tracker for usage questions. The README asks posters to be specific, include code samples and output, and reduce example code as much as possible. There is no documented chat channel, no commercial support tier, and no stated response time. For a team evaluating Prawn, that means the practical support story is community volunteers plus a mailing list mentioned in the contributing section.

Contributing has its own conventions worth knowing if you plan to send patches. The README asks for failing tests or a reduced example with bug reports, and for tests, API documentation and manual updates with patches. The test suite runs through rake for the full suite excluding unresolved issues, rspec for everything including unresolved issues, rspec -t unresolved for only those, and rspec -t issue:NUMBER for a specific issue. That tagging scheme is how the project keeps known-failing tests in the tree without breaking the default run.

Prawn compared with rendering HTML through a browser

The alternative the README itself names is Ferrum, which it recommends for HTML to PDF conversion. The difference is architectural rather than a matter of quality. Ferrum drives a browser and prints a page, so the document's layout comes from HTML and CSS and the browser's rendering engine. Prawn has no rendering engine for markup; you place text and shapes yourself, and the PDF is assembled from your drawing calls.

That choice determines where the work sits. With a browser-based pipeline, the layout work is front-end work and the Ruby side hands over markup and data. With Prawn, the layout work is Ruby code, and the README's grid system and bounding box model are the tools you use to keep it organized. Prawn's advantage is that it is pure Ruby with runtime dependencies maintained by the project, which the README says should let it run pretty much anywhere, including JRuby versions matching the supported Ruby versions. A browser-based pipeline has a browser in the dependency graph.

The trade-off runs the other way when the document is design-led. Rich typography, complex tables and anything that looks like a web page are easier to express in HTML and CSS, and Prawn's inline formatting is limited by design. Neither approach is a superset of the other.

Editorial conclusion

Adopt Prawn when the document is generated from data you already hold in Ruby and you want control over placement, fonts and page furniture rather than a browser rendering pipeline. Do not adopt it if your source of truth is an HTML template or a web page, because the README states it is not and will never be an HTML to PDF generator; Ferrum is the project's own pointer for that job. Before committing, verify three things against your own output: that the TrueType fonts you need render your scripts correctly, that your gem lockfile pins a version whose CHANGELOG entries you have read, and that the encryption and password protection options cover the access rules your document requires.

Frequently asked questions

Is Prawn an HTML to PDF generator?

No. The README states that Prawn is not, and will never be, an HTML to PDF generator, and points to Ferrum for those needs. It has basic inline styling support, but the README describes that as a very small subset and unsuitable for rich HTML documents.

How do I install Prawn?

Prawn is distributed via RubyGems and installs with the standard gem command. The README also notes that you can install from git, where the master branch holds the latest developments but may have rough edges and fresh bugs.

Does Prawn follow Semantic Versioning?

Not formally. The README says the project ships experimental APIs whose stability it does not promise, and that only the stable portion of the API is assumed to follow Semantic Versioning. It also states that bug fixes can change behaviour and are not treated as breaking changes, so it advises reading CHANGELOG.md on each release and locking your gems.

Which Ruby versions does Prawn support?

The README says Prawn officially supports all Ruby versions supported by the Ruby Core Team, plus JRuby versions of matching Ruby version. Because Prawn is pure Ruby and its runtime dependencies are maintained by the project, it should work pretty much anywhere, and patches for other platforms are accepted if they are not too invasive.

How do I get help with Prawn?

The README directs users to the project's GitHub Discussions, which it describes as responsive. It asks posters to include code samples and output where relevant, avoid sharing non-public information, and reduce example code as much as possible.

Official sources

  1. Issues
  2. prawnpdf/prawn on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/prawnpdf-prawn.svg)](https://hysenlabs.com/projects/prawnpdf-prawn)