Forms · Ruby

Create and fill PDF forms in Ruby

Build interactive AcroForm fields from Ruby (text inputs, checkboxes, radio groups and dropdowns) with generated appearance streams, then fill and flatten them later. No NeedAppearances hack required.

Last updated: 2026-06-29

Why Ruby needs this

Prawn can draw a form that looks right but is not interactive, so Ruby teams have leaned on a pdftk binary or a Java library to make fields fillable. rust-pdf authors a real AcroForm and the appearance streams to go with it.

Every field is emitted with a generated appearance stream, so checkboxes, text inputs and choices render correctly in every viewer without the NeedAppearances workaround. Dotted names give you a hierarchy for grouped data, and an existing form can be filled and flattened into static content.

Author or fill the form from a Rails controller or a Sidekiq worker, chaining text_field, checkbox, dropdown and radio_group on a page, then save; it binds through Fiddle, so there is no pdftk subprocess and a bad load is a RustPdf::Error to rescue.

  • Text fields, checkboxes, radio groups and dropdowns with generated appearance streams.
  • Hierarchical dotted field names for grouped data.
  • Fill an existing form and flatten it into non-editable content.

Build a form in Ruby with rust-pdf

Install with RubyGems, then call the same idiomatic API every rust-pdf binding shares. The snippet below is real Ruby code from the reference docs.

gem install rustpdf

Ruby
doc = RustPdf::Document.new
doc.add_page
   .text_field("applicant.name", 0, [72, 700, 320, 720], value: "")
   .checkbox("agree", 0, [72, 660, 88, 676], false)
   .dropdown("plan", 0, [72, 620, 240, 640],
             ["Starter", "Pro", "Enterprise"], selected: 1)
   .radio_group("billing", 0, [
     [[72, 580, 88, 596], "monthly"],
     [[140, 580, 156, 596], "annual"],
   ], selected: 1)
doc.save("form.pdf")
doc.close
Validated by: qpdfmutool

This is part of the free tier in Ruby. No license required.

Full Ruby reference in the documentation.

Forms in Ruby: FAQ

Do the form fields render without NeedAppearances in Ruby?

Yes. rust-pdf generates an appearance stream for every field, so checkboxes, text and choices display correctly in all viewers without the NeedAppearances workaround.

Can I fill an existing form in Ruby?

Yes. Load the PDF, set text fields, checkboxes, radios and dropdowns by name, and optionally flatten the form so the values become permanent static content.

Is form authoring free?

Yes. Creating, filling and flattening AcroForm fields is part of the free tier in Ruby.

Can I fill an uploaded form in a Rails app?

Yes. Load the PDF in a controller or a Sidekiq worker, set fields by their dotted names, and optionally flatten so the values become static content. It binds through Fiddle with no pdftk subprocess, and a malformed file is a RustPdf::Error you can rescue.

Put interactive PDF forms in your Ruby app

One Rust core, the same output across every language. Prototype for free, license the corporate features when you ship.