Authoring · Ruby
Generate a PDF in Ruby
Create PDFs programmatically from Ruby: pages, vector graphics, embedded and subset fonts with full Unicode shaping, justified paragraphs, tables and images. rust-pdf gives Ruby a fast, memory-safe core with deterministic output.
Why Ruby needs this
Prawn generates beautiful PDFs but has no PDF/A, no digital signatures, no AES-256 and no PDF/UA, so the regulated features have simply been missing from Ruby.
Generation is the free foundation. Draw shapes, place shaped and kerned Unicode text, lay out wrapping paragraphs, embed JPEG and PNG images, and add links and bookmarks. Output is deterministic (the same input yields the same bytes), which makes it auditable and testable.
- Vector graphics, embedded and subset fonts, HarfBuzz-quality Unicode shaping and kerning.
- Wrapping and justified paragraphs, tables, images (JPEG, PNG, alpha, 16-bit).
- Deterministic output: identical bytes for identical input, ideal for audits and tests.
Generate a PDF in Ruby with rust-pdf
Install the package, then call the same idiomatic API every rust-pdf binding shares. The snippet below is real Ruby code from the reference docs.
require "rustpdf"
doc = RustPdf::Document.new # A4 by default
doc.add_page
.fill_rgb(0.86, 0.20, 0.18)
.rect(72, 640, 200, 120) # x, y, width, height (points)
.fill
doc.save("out.pdf")
doc.close
This is part of the free tier in Ruby. No license required.
Full Ruby reference in the documentation.
Generation in Ruby: FAQ
Is generating PDFs free in Ruby?
Yes. All basic generation (pages, graphics, fonts, text, paragraphs, images, links, bookmarks, watermarks) is free forever. You only license corporate features such as PDF/A, signatures and encryption when you ship them.
Does it support Unicode and custom fonts?
Yes. Fonts are embedded and subset with HarfBuzz-quality shaping and kerning, using Type0 fonts with ToUnicode, so non-Latin scripts render and extract correctly.
Why a Rust core for Ruby?
One memory-safe, high-performance Rust core is exposed to Ruby through a thin idiomatic binding. You get the same engine, the same features and deterministic output, without a heavy runtime.
Generate a PDF in Ruby
One Rust core, the same output across every language. Prototype for free, license the corporate features when you ship.