v14.2
<rapi-pdf> • rapipdf

RapiPdf

Turn an OpenAPI 3.x or Swagger 2.0 spec into a PDF reference: in the browser with <rapi-pdf>, in Node with rapipdf/node, or in CI with rapidoc pdf. Same document every way.

Live

Make One Now

This is the element itself, pointed at the Petstore spec. Change the URL to any spec your browser can fetch, and press the button: the PDF opens in a new tab. The generator, about two megabytes, loads on the first click.

Default
Schemas as tables, with examples, downloaded
The Document

What Goes in the PDF

Each part can be left out with an attribute or a command-line option, so the PDF can be a full reference or a short list of operations.

Cover and contents

A cover page with the title you set, the API's description, version and contact, and a table of contents.

Security schemes

API keys, HTTP auth, OAuth 2.0 flows and OpenID Connect, as the spec declares them.

Every operation

Grouped by tag: parameters, request bodies and responses, with their schemas. Examples on request.

Schemas as trees or tables

pdf-schema-style prints schemas as an indented object or as a table.

Your title and colors

Set the cover title, a footer on every page, and the two colors used for headings and links.

Any language

Replace the printed labels with JSON. From the command line, add your own font for scripts Roboto lacks.

Three Ways

In the Browser, in Node, in CI

In the browser

One script tag. rapipdf-min.js is a classic script with everything in it; with a bundler,import "rapipdf" gives a few-kilobyte element that fetches the generator the first time a PDF is asked for.

Attributes choose what goes in the PDF; generatePdf() and getPdfBlob() make one from a script. All of them are in the API reference, and the RapiPdf docs walk through them.

index.html
<script src="https://unpkg.com/rapipdf/dist/rapipdf-min.js"></script>

<rapi-pdf
  spec-url="https://petstore3.swagger.io/api/v3/openapi.json"
  pdf-title="Petstore API"
  include-example="true"
></rapi-pdf>

In Node

rapipdf/node builds the same document from a file, a URL or a spec object and returns it as a Buffer: for a build step that publishes the PDF next to your docs.

make-pdf.mjs
import { writeFile } from "node:fs/promises";
import { generatePdf } from "rapipdf/node";

const pdf = await generatePdf("openapi.yaml", { pdfTitle: "Orders API" });
await writeFile("reference.pdf", pdf);

On the command line

rapidoc pdf of the RapiDoc CLI writes the PDF from a spec, with an option for each attribute, plus your own fonts and labels.

Every option

terminal
npm install -D @rapidoc/cli rapipdf

npx rapidoc pdf openapi.yaml
npx rapidoc pdf openapi.yaml -o dist/reference.pdf --title "Orders API" --examples

Next to Your Reference

Readers who want the reference offline can download it from the same page as <rapi-doc>.