Project

arrolio

0.0
The project is in a healthy, maintained state
Arrolio is a paged-media layout engine: it takes a content tree plus a layout spec (page templates, styles, flows) and produces a sequence of laid-out pages, which a renderer then emits — by default to PDF bytes via the sibling `pdfrb` gem. Arrolio is the middle layer of a three-library stack: * `pdfrb` — pure-Ruby PDF library (bytes <-> model). * `arrolio` — FOP-like paged layout (this gem; depends on pdfrb). * `loom` — multi-target layout compiler (separate gem; emits to Arrolio, CSS, XSL-FO, IDML). Arrolio itself owns: page templates, threaded flows, Knuth-Plass line and page breaking, tables, lists, SVG, page-model selection, running headers/footers, and the rendering pipeline. It does not own the PDF byte format (Pdfrb does) or any DSL (Loom does).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 0.4.45, < 1.0
~> 0.3.0
>= 0
 Project Readme

Arrolio

FOP-like paged layout engine for Ruby. Renders to PDF via the sibling pdfrb gem.

What this is

Arrolio is the middle layer of a three-library stack:

Library Owns Depends on

pdfrb

Pure-Ruby PDF library (bytes ↔ model; streams, fonts, xref, encryption)

arrolio (this gem)

FOP-like paged layout: page templates, threaded flows, Knuth-Plass line/page breaking, tables, lists, SVG, page-model selection, running headers/footers

pdfrb

loom (separate gem, not yet built)

Multi-target layout compiler. Compiles a higher-level DSL to Arrolio’s IR, plus CSS, XSL-FO, and IDML.

arrolio (for the PDF target only)

Arrolio’s job: take a content tree plus a layout spec, produce a sequence of laid-out pages, render those to PDF (or, in future, to other paged formats).

Two-direction contract

  • Content + LayoutSpec → Arrolio::Engine::Paged → Output::Page[] (the layout pass).

  • Output::Page[] → Arrolio::Renderer::Pdf → bytes (the render pass; uses Pdfrb internally).

Quick start

require "arrolio"

content = Arrolio::Content::Document.new
content.add_section("Introduction", level: 1) do |section|
  section.add_paragraph("Hello, World!")
end

layout = Arrolio::LayoutSpec.new
layout.add_page_template(:body, page_size: :A4, margins: 25)
layout.add_style(:body, font: "Times-Roman", size: 11)

engine   = Arrolio::Engine::Paged.new(layout)
pages    = engine.layout(content)
renderer = Arrolio::Renderer::Pdf.new

File.binwrite("out.pdf", renderer.render(pages))

Higher-level convenience API:

Arrolio.compose("out.pdf") do |doc|
  doc.page_size = :A4
  doc.margins   = 25
  doc.heading "Introduction"
  doc.text   "Hello, World!"
end

Where Arrolio’s responsibilities end

Arrolio deliberately does not own:

  • PDF byte format — that’s Pdfrb’s job.

  • DSL authoring (YAML, FO XML, etc.) — that’s Loom’s job.

  • Multi-target compilation (CSS / XSL-FO / IDML) — Loom.

  • The semantic content model — that’s metanorma-document (or any conforming source). Arrolio defines a contract, not an implementation.

Status

Pre-1.0. The skeleton lands first; modules port incrementally from Pdfrb::Layout::* (which will eventually be removed from Pdfrb once Arrolio is stable).

License

BSD-2-Clause. See LICENSE.