PDF generation for Ruby

PDFs that keep their text.

Create precise documents with embedded fonts. Text stays searchable and copyable, and the same input produces the same PDF.

Illustrative PDF document

Everything in the document stays useful.

Build reports, exports, and print-ready pages without turning text into a picture.

Searchable by design

Embed TrueType and supported CFF1 font subsets with ToUnicode mappings, including Japanese text when the font has the glyphs.

Room to compose

Place text and images alongside vector paths, clipping, links, and document outlines.

Predictable output

Generate deterministic PDF 1.7 files without timestamps changing the result.

Start with a font and a page.

Okab requires Ruby 3.2 or newer. Supply a font containing the glyphs you want to render.

Install
gem install okab
Write a PDF
require "okab"

font = Okab::Font.load("report.ttf")
document = Okab::Document.new(title: "Report")
page = document.page(width: 595, height: 842)
page.text("Report", x: 48, y: 790, font: font, size: 24)
document.write("report.pdf")

For the complete API and supported formats, read the documentation.