explaingit

prawnpdf/prawn

4,799RubyAudience · developerComplexity · 2/5Setup · easy

TLDR

A Ruby library for building PDF files entirely from code, draw text, shapes, images, and multi-page layouts from scratch to generate invoices, certificates, or custom reports.

Mindmap

mindmap
  root((Prawn))
    Content types
      Text with custom fonts
      Shapes and curves
      PNG and JPG images
      Multi-page layout
    Features
      Headers and footers
      Page numbers
      PDF bookmarks
      Password protection
    Internationalization
      UTF-8 support
      Right-to-left text
      Fallback fonts
    Use cases
      Invoices
      Certificates
      Custom reports
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Generate PDF invoices from database records in a Ruby on Rails application.

USE CASE 2

Build certificates or reports with precise layout control, custom TrueType fonts, and embedded images.

USE CASE 3

Create multi-page documents with automatic repeating headers, footers, and page numbers.

USE CASE 4

Produce internationalized PDFs with UTF-8 text and right-to-left language support for Arabic or Hebrew content.

Tech stack

Ruby

Getting it running

Difficulty · easy Time to first run · 30min

Install via gem install prawn, embedding custom TrueType fonts requires providing the font files in your project.

In plain English

Prawn is a Ruby library that lets developers build PDF files entirely from code. Rather than converting a web page or a template into a PDF, it gives you a set of tools to draw and place content on a page from scratch: text, shapes, images, and layout structures. You call it from a Ruby program and it produces a working PDF file as output. The library handles a wide range of content types. You can draw lines, curves, polygons, and ellipses on a page. You can place flowing text with support for TrueType fonts you embed yourself, or fall back to the standard fonts that the PDF format includes by default. Images in PNG or JPG format can be placed and scaled. For documents that span many pages, you can define repeating content like headers, footers, and page numbers so they appear automatically on every page. Prawn also covers internationalization in some depth. It supports UTF-8 text, right-to-left writing for languages like Arabic and Hebrew, and fallback fonts for characters that one font does not cover. There is also a simple grid system for basic layout, support for PDF bookmarks that let readers jump between sections, and optional password protection and encryption for sensitive documents. One thing the README is clear about: Prawn is not an HTML-to-PDF tool. If you have an existing web page you want to turn into a PDF, this is not the right fit. It is designed for situations where you want precise, programmatic control over what goes on each page, such as generating invoices, certificates, or custom reports from data in a Ruby application. Installing it is straightforward with the standard Ruby package manager. The project includes a manual, built from examples in the repository, that walks through most of the available features. The project is actively maintained and accepts community contributions through GitHub.

Copy-paste prompts

Prompt 1
Using the Prawn Ruby gem, write code that generates a PDF invoice with a company header, an itemized table of line items, a subtotal, tax, and a total, then saves it to disk.
Prompt 2
Write a Prawn PDF that has a repeating header and footer on every page, includes page numbers, and places a PNG logo image in the top-right corner of each page.
Prompt 3
Using Prawn, generate a certificate PDF with a custom TrueType font, a decorative rectangular border, and centered text for the recipient's name and award title.
Prompt 4
Show me how to use Prawn's grid layout system to organize content into two columns for a multi-section report generated from a Ruby hash of data.
Open on GitHub → Explain another repo

← prawnpdf on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.