Skip to content

About

Native HTML-to-PDF rendering for Ruby and Rails using Forme, without a browser or WebAssembly

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

forme-ruby

CI License: MIT

Render HTML and print CSS to PDF inside Ruby, using the Rust Forme engine. No browser, Node.js, WebAssembly or separate rendering service is needed.

This is an independent MIT-licensed binding maintained by ClearStack, not an official upstream project. 0.2.0 is available on RubyGems.

Getting started

Add to your Gemfile and run bundle install:

gem "forme-ruby", "~> 0.2.0", require: "forme_pdf"

Or install directly:

gem install forme-ruby -v 0.2.0

RubyGems selects a matching native package where available. The same packages and checksums are available in the GitHub release.

require "forme_pdf"

pdf = FormePDF.render_html("<h1>Hello from Ruby</h1>")
File.binwrite("hello.pdf", pdf)

Requirements

  • Ruby 3.3 or later.
  • Native gems: macOS 15+ on Apple Silicon, or Linux AMD64 with glibc 2.28+.
  • Source gem: Rust/Cargo 1.94.0, a C linker, make and network access to the locked upstream dependencies.

See the installation guide.

Using Rails

Authorize and select application data first, then render explicitly:

html = render_to_string(template: "invoices/pdf", layout: "pdf", formats: [:html])
send_data FormePDF.render_html(html),
  type: "application/pdf", disposition: "inline", filename: "invoice.pdf"

Rails is optional. The Rails guide also covers the opt-in FormePDF::Rails adapter. The gem installs no middleware or routes.

Learn more

Use trusted HTML and assets. Local image files are read only inside an explicit image_root:, and the engine is not a sandbox for untrusted documents. See security. Report reproducible bugs through GitHub issues with synthetic input, Ruby/platform versions and renderer diagnostics.

About

Native HTML-to-PDF rendering for Ruby and Rails using Forme, without a browser or WebAssembly

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages