Ruby PDF libraries

Updated Nov 2026

Ruby PDF libraries generate, read, and modify PDF documents from Ruby code. A generator either draws pages with its own layout commands or converts HTML through an external renderer such as wkhtmltopdf. These libraries let Rails apps, billing systems, and reporting jobs produce invoices, reports, and forms as PDF files.

Popularity

PDF::Reader has the most monthly downloads in this comparison, at 119574974.

LibraryMonthly downloadsStarsLast releaseLicense
PDF::Reader
119574974
1.9KAug 2026MIT
Prawn
109466447
4.8KMar 2024Modified Ruby license OR GPL-2.0-only OR GPL-3.0-only
Wicked PDF
88673892
3.6KOct 2024MIT
combine_pdf
63487617
785Apr 2025MIT
pdfkit
31048099
2.9KMay 2023MIT
pdf-inspector
24766071
182Mar 2017Modified Ruby license OR GPLv2 OR GPLv3
HexaPDF
15347097
1.4KOct 2026AGPL-3.0 OR commercial
pdf-forms
9437249
304Feb 2025MIT
Downloads: RubyGems, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Provides programmatic access to PDF file contents.

Downloads / mo
119574974
Stars
1.9K
Last release
2.16.0
License
MIT

Strengths

  • Exposes document-level information. Read metadata and page counts from one reader.
  • Returns text in UTF-8. Receive text in UTF-8 regardless of the document’s internal encoding.

Limitations

  • Unrecognized text becomes replacement characters. Invalid stored bytes can appear as a replacement box.

Quickstart

From pdf-reader.md
$ gem install pdf-reader -v 2.16.0
require "pdf/reader"

reader = PDF::Reader.new("input.pdf")
puts reader.page_count

PDF::Reader examples

From open-source projects on GitHub

Generates PDF documents using Ruby.

Downloads / mo
109466447
Stars
4.8K
Last release
2.5.0
License
Modified Ruby license OR GPL-2.0-only OR GPL-3.0-only

Strengths

  • Draws vector shapes and text. Combine lines, curves, flowing text, and embedded fonts.
  • Repeats headers and page numbers. Render repeated content across document pages.

Limitations

  • Cannot convert full HTML pages. Use a browser renderer when the source is a full HTML page.

Quickstart

From README.md
$ gem install prawn -v 2.5.0
require "prawn"

Prawn::Document.generate("hello.pdf") do |pdf|
  pdf.text "Hello World!"
end

Serves a PDF file generated from HTML through the wkhtmltopdf shell utility.

Downloads / mo
88673892
Stars
3.6K
Last release
2.8.2
License
MIT

Quickstart

From README.md
$ gem install wicked_pdf -v 2.8.2
require "wicked_pdf"

pdf = WickedPdf.new.pdf_from_string("<h1>Hello World!</h1>")
File.binwrite("hello.pdf", pdf)

Wicked PDF examples

From open-source projects on GitHub
def notify_client_with_pdf_invoice_attachment(current_user, id = nil)
    invoice_string  = ApplicationController.new.render_to_string('invoices/show.html.erb', layout: 'pdf_mode', locals: {invoice: self})
    invoice_pdf_file = WickedPdf.new.pdf_from_string(invoice_string)
    notify(current_user, self.id, invoice_pdf_file)
  end

Merges PDF documents and overlays existing page content using Ruby.

Downloads / mo
63487617
Stars
785
Last release
1.0.31
License
MIT

Strengths

  • Merges whole documents or pages. Append complete PDFs or select individual pages to combine.
  • Overlays existing PDF page content. Load a logo page and overlay it on existing pages.

Limitations

  • Original maintenance has stopped. Evaluate maintenance coverage before adopting it for new production workflows.
  • Merging can unify form fields. Matching field names can link their values across merged forms.
  • Page-only merges can lose links. Combine whole documents when preserving links and named destinations.

Quickstart

From README.md
$ gem install combine_pdf -v 1.0.31
require "combine_pdf"

pdf = CombinePDF.load("input.pdf")
pdf.save("output.pdf")

combine_pdf examples

From open-source projects on GitHub

Creates PDFs from HTML with wkhtmltopdf.

Downloads / mo
31048099
Stars
2.9K
Last release
0.8.7.3
License
MIT

Quickstart

From README.md
$ gem install pdfkit -v 0.8.7.3
require "pdfkit"

kit = PDFKit.new("<h1>Hello World!</h1>")
kit.to_file("hello.pdf")

pdfkit examples

From open-source projects on GitHub

pdf-inspector

Inspects PDF output with analysis classes based on PDF::Reader, mainly for testing Prawn.

Downloads / mo
24766071
Stars
182
Last release
1.3.0
License
Modified Ruby license OR GPLv2 OR GPLv3

Quickstart

From README.md
$ gem install pdf-inspector -v 1.3.0
require "pdf/inspector"

analysis = PDF::Inspector::Text.analyze(File.binread("input.pdf"))
p analysis.strings

Creates PDF files and manipulates existing documents.

Downloads / mo
15347097
Stars
1.4K
Last release
1.11.2
License
AGPL-3.0 OR commercial

Strengths

  • Edits existing PDF structures. Modify document objects or content before writing the PDF again.
  • Fills predefined PDF form fields. Assign values to AcroForm fields using a data hash.

Limitations

  • Nonblock opening buffers the file. Opening without a block reads the whole file into memory.

Quickstart

From README.md
$ gem install hexapdf -v 1.11.2
require "hexapdf"

doc = HexaPDF::Document.new
canvas = doc.pages.add.canvas
canvas.font("Helvetica", size: 100)
canvas.text("Hello World!", at: [20, 400])
doc.write("hello.pdf")

HexaPDF examples

From open-source projects on GitHub

Fills PDF templates from a data hash through the pdftk binary, with FDF and XFDF creation.

Downloads / mo
9437249
Stars
304
Last release
1.5.2
License
MIT

Quickstart

From README.md
$ gem install pdf-forms -v 1.5.2
require "pdf_forms"

pdftk = PdfForms.new("pdftk")
pdftk.fill_form("input.pdf", "output.pdf", {"foo" => "bar"})

pdf-forms examples

From open-source projects on GitHub

FAQ

Prawn suits PDFs drawn from Ruby with vector shapes, flowing text, and embedded fonts. Wicked PDF suits PDFs rendered from HTML through wkhtmltopdf. PDF::Reader suits reading text and metadata from existing PDFs.

Wicked PDF uses the wkhtmltopdf shell utility to serve a PDF file generated from HTML.

No. Prawn cannot convert full HTML pages. Those need a browser renderer or an HTML-based tool such as Wicked PDF.

combine_pdf appends complete PDFs or selected pages. Its original maintenance has stopped.

HexaPDF assigns values to AcroForm fields from a data hash. pdf-forms fills templates through the pdftk binary.

For coding agents

Found your PDF library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official