# Ruby PDF libraries

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

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [PDF::Reader](#pdf-reader) | 119574974 | 1.9K | Aug 2026 | MIT |
| [Prawn](#prawn) | 109466447 | 4.8K | Mar 2024 | Modified Ruby license OR GPL-2.0-only OR GPL-3.0-only |
| [Wicked PDF](#wicked-pdf) | 88673892 | 3.6K | Oct 2024 | MIT |
| [combine_pdf](#combinepdf) | 63487617 | 785 | Apr 2025 | MIT |
| [pdfkit](#pdfkit) | 31048099 | 2.9K | May 2023 | MIT |
| [pdf-inspector](#pdf-inspector) | 24766071 | 182 | Mar 2017 | Modified Ruby license OR GPLv2 OR GPLv3 |
| [HexaPDF](#hexapdf) | 15347097 | 1.4K | Oct 2026 | AGPL-3.0 OR commercial |
| [pdf-forms](#pdf-forms) | 9437249 | 304 | Feb 2025 | MIT |

Downloads: RubyGems, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[PDF::Reader](#pdf-reader) has the most monthly downloads in this comparison, at 119574974.

## Capabilities

| Library | Existing PDF input | Browser HTML to PDF |
| --- | --- | --- |
| [PDF::Reader](#pdf-reader) | Yes | No |
| [Prawn](#prawn) | No | No |
| [Wicked PDF](#wicked-pdf) | No | Yes |
| [combine_pdf](#combinepdf) | Yes | No |
| [pdfkit](#pdfkit) | No | Yes |
| [pdf-inspector](#pdf-inspector) | Yes | No |
| [HexaPDF](#hexapdf) | Yes | No |
| [pdf-forms](#pdf-forms) | Yes | No |

## Libraries

### PDF::Reader

[GitHub](https://github.com/yob/pdf-reader) · [RubyGems](https://rubygems.org/gems/pdf-reader) · [Docs](https://www.rubydoc.info/gems/pdf-reader/2.16.0)

Provides programmatic access to PDF file contents.

- Downloads / mo: 119574974
- Stars: 1.9K
- Last release: 2.16.0
- License: MIT
- Capabilities: [From the PDF::Reader docs](https://www.rubydoc.info/gems/pdf-reader/2.16.0)

**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.

**Watch out for**

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

```sh
gem install pdf-reader -v 2.16.0
```

**huginn/huginn** (50.6K stars)

[huginn/huginn](https://github.com/huginn/huginn) 

```ruby
def check_url(in_url, payload)
      return unless in_url.present?

      Array(in_url).each do |url|
        uri = URI(url) rescue nil
        unless uri.is_a?(URI::HTTP)
          error "Unsupported URL: #{url}"
          next
        end

        log "Fetching #{url}"
        response = faraday.get(url)
        reader = PDF::Reader.new(StringIO.new(response.body))

        info = reader.info.to_h { |key, value|
          [key.to_s, decode_pdf_date(value) || value]
        }
        info["Pages"] = reader.page_count.to_s
        if (page = reader.pages.first)
          info["Page size"] = "#{page.width} x #{page.height} pts"
        end
        info["PDF version"] = reader.pdf_version.to_s

        create_event payload: info.merge(payload)
      end
    end
```

[app/models/agents/pdf_info_agent.rb](https://github.com/huginn/huginn/blob/639c050b2bf4e14ef9983012af99dfc1dc68b334/app/models/agents/pdf_info_agent.rb#L61-L86) · [More projects using PDF::Reader →](https://dashboard.exa.ai/playground/search?q=Ruby%20applications%20using%20pdf-reader%20for%20PDF%20report%20layouts%20form%20filling%20metadata%20extraction%20and%20document%20merging&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```ruby
require "pdf/reader"

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

```

From [pdf-reader.md](https://github.com/yob/pdf-reader)

### Prawn

[GitHub](https://github.com/prawnpdf/prawn) · [RubyGems](https://rubygems.org/gems/prawn) · [Docs](https://prawnpdf.org/docs/prawn/2.5.0/)

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
- Capabilities: [From the Prawn docs](https://prawnpdf.org/docs/prawn/2.5.0/)

**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.

**Watch out for**

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

```sh
gem install prawn -v 2.5.0
```

**Quickstart**

```ruby
require "prawn"

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

```

From [README.md](https://github.com/prawnpdf/prawn) · [Find projects using Prawn →](https://dashboard.exa.ai/playground/search?q=Ruby%20applications%20using%20prawn%20for%20PDF%20report%20layouts%20form%20filling%20metadata%20extraction%20and%20document%20merging&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

### Wicked PDF

[GitHub](https://github.com/mileszs/wicked_pdf) · [RubyGems](https://rubygems.org/gems/wicked_pdf)

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
- Capabilities: [From the Wicked PDF docs](https://github.com/mileszs/wicked_pdf)

```sh
gem install wicked_pdf -v 2.8.2
```

**vteams/open-source-billing** (775 stars)

[vteams/open-source-billing](https://github.com/vteams/open-source-billing) 

```ruby
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
```

[app/models/invoice.rb](https://github.com/vteams/open-source-billing/blob/61cd6edfd224200b2d10ac1ac613444e96d5769a/app/models/invoice.rb#L292-L296) · [More projects using Wicked PDF →](https://dashboard.exa.ai/playground/search?q=wicked_pdf%20GitHub%20projects)

**Quickstart**

```ruby
require "wicked_pdf"

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

```

From [README.md](https://github.com/mileszs/wicked_pdf)

### combine_pdf

[GitHub](https://github.com/boazsegev/combine_pdf) · [RubyGems](https://rubygems.org/gems/combine_pdf) · [Docs](https://www.rubydoc.info/gems/combine_pdf/1.0.31)

Merges PDF documents and overlays existing page content using Ruby.

- Downloads / mo: 63487617
- Stars: 785
- Last release: 1.0.31
- License: MIT
- Capabilities: [From the combine_pdf docs](https://www.rubydoc.info/gems/combine_pdf/1.0.31)

**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.

**Watch out for**

- **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.

```sh
gem install combine_pdf -v 1.0.31
```

**openfoodfoundation/openfoodnetwork** (1.3K stars)

[openfoodfoundation/openfoodnetwork](https://github.com/openfoodfoundation/openfoodnetwork) 

```ruby
def generate_invoice(order)
    renderer_data = if OpenFoodNetwork::FeatureToggle.enabled?(:invoices, current_user)
                      Orders::GenerateInvoiceService.new(order).generate_or_update_latest_invoice
                      order.invoices.first.presenter
                    else
                      order
                    end
    invoice = renderer.render_to_string(renderer_data, current_user)
    pdf << CombinePDF.parse(invoice)
  end
```

[app/jobs/bulk_invoice_job.rb](https://github.com/openfoodfoundation/openfoodnetwork/blob/a1bc64fc67356a06808558635e442a7d77c38ae0/app/jobs/bulk_invoice_job.rb#L30-L39) · [More projects using combine_pdf →](https://dashboard.exa.ai/playground/search?q=Ruby%20applications%20using%20combine_pdf%20for%20PDF%20report%20layouts%20form%20filling%20metadata%20extraction%20and%20document%20merging&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```ruby
require "combine_pdf"

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

```

From [README.md](https://github.com/boazsegev/combine_pdf)

### pdfkit

[GitHub](https://github.com/pdfkit/pdfkit) · [RubyGems](https://rubygems.org/gems/pdfkit) · [Docs](https://www.rubydoc.info/gems/pdfkit/0.8.7.3)

Creates PDFs from HTML with wkhtmltopdf.

- Downloads / mo: 31048099
- Stars: 2.9K
- Last release: 0.8.7.3
- License: MIT
- Capabilities: [From the pdfkit docs](https://www.rubydoc.info/gems/pdfkit/0.8.7.3)

```sh
gem install pdfkit -v 0.8.7.3
```

**binford2k/showoff** (948 stars)

[binford2k/showoff](https://github.com/binford2k/showoff) 

```ruby
def pdf(name)
      @slides = get_slides_html(:static=>true, :toc=>true, :print=>true)
      @inline = true

      html = erb :onepage

      # Process inline css and js for included images
      # The css uses relative paths for images and we prepend the file url
      html.gsub!(/url\([\"\']?(?!https?:\/\/)(.*?)[\"\']?\)/) do |s|
        "url(file://#{settings.pres_dir}/#{$1})"
      end

      # remove the weird /files component, since that doesn't exist on the filesystem
      # replace it for file://<PATH> for correct use with wkhtmltopdf (exactly with qt-webkit)
      html.gsub!(/<img src=".\/file\/([^"]*)/) do |s|
        "<img src=\"file:\/\/#{settings.pres_dir}\/#{$1}"
      end

      # PDFKit.new takes the HTML and any options for wkhtmltopdf
      # run `wkhtmltopdf --extended-help` for a full list of options
      kit = PDFKit.new(html, ShowoffUtils.showoff_pdf_options(settings.pres_dir))

      # Save the PDF to a file
      kit.to_file(name)
    end
```

[lib/showoff.rb](https://github.com/binford2k/showoff/blob/8c06a49deb8ea788ca509b7d13806c26d449f874/lib/showoff.rb#L1447-L1471) · [More projects using pdfkit →](https://dashboard.exa.ai/playground/search?q=pdfkit%20GitHub%20projects)

**Quickstart**

```ruby
require "pdfkit"

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

```

From [README.md](https://github.com/pdfkit/pdfkit)

### pdf-inspector

[GitHub](https://github.com/prawnpdf/pdf-inspector) · [RubyGems](https://rubygems.org/gems/pdf-inspector) · [Docs](https://www.rubydoc.info/gems/pdf-inspector/1.3.0)

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
- Capabilities: [From the pdf-inspector docs](https://www.rubydoc.info/gems/pdf-inspector/1.3.0)

```sh
gem install pdf-inspector -v 1.3.0
```

**Quickstart**

```ruby
require "pdf/inspector"

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

```

From [README.md](https://github.com/prawnpdf/pdf-inspector) · [Find projects using pdf-inspector →](https://dashboard.exa.ai/playground/search?q=pdf-inspector%20GitHub%20projects)

### HexaPDF

[GitHub](https://github.com/gettalong/hexapdf) · [RubyGems](https://rubygems.org/gems/hexapdf) · [Docs](http://hexapdf.gettalong.org/)

Creates PDF files and manipulates existing documents.

- Downloads / mo: 15347097
- Stars: 1.4K
- Last release: 1.11.2
- License: AGPL-3.0 OR commercial
- Capabilities: [From the HexaPDF docs](http://hexapdf.gettalong.org/)

**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.

**Watch out for**

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

```sh
gem install hexapdf -v 1.11.2
```

**decidim/decidim** (1.9K stars)

[decidim/decidim](https://github.com/decidim/decidim) 

```ruby
def signed_pdf
      signed_file = Tempfile.new("signed_pdf")

      doc = HexaPDF::Document.new(io: StringIO.new(pdf))

      # Prepare the document for embedding of the digital signature
      data = nil # Used for storing the to-be-signed data
      signing_mechanism = lambda do |io, byte_range|
        # Store the to-be-signed data in the local variable data
        io.pos = byte_range[0]
        data = io.read(byte_range[1])
        io.pos = byte_range[2]
        data << io.read(byte_range[3])
        ""
      end
      doc.sign(signed_file.path, signature: signature_widget(doc), reason: caption, signature_size: 10_000, external_signing: signing_mechanism)

      signature = OpenSSL::PKCS7.sign(certificate, key, data,
                                      # [HexaPDF.demo_cert.sub_ca, HexaPDF.demo_cert.root_ca],
                                      [],
                                      OpenSSL::PKCS7::DETACHED | OpenSSL::PKCS7::BINARY).to_der

      # Embed the signature
      HexaPDF::DigitalSignature::Signing.embed_signature(File.open(signed_file.path, "rb+"), signature)

      File.binread(signed_file.path)
    ensure
      signed_file.close
      signed_file.unlink
    end
```

[decidim-core/lib/decidim/pdf_signature_example.rb](https://github.com/decidim/decidim/blob/4f1760c5884e5bf2beb82a05bf467bf5ffe5d0b2/decidim-core/lib/decidim/pdf_signature_example.rb#L18-L47) · [More projects using HexaPDF →](https://dashboard.exa.ai/playground/search?q=Ruby%20applications%20using%20hexapdf%20for%20PDF%20report%20layouts%20form%20filling%20metadata%20extraction%20and%20document%20merging&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```ruby
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")

```

From [README.md](https://github.com/gettalong/hexapdf)

### pdf-forms

[GitHub](https://github.com/jkraemer/pdf-forms) · [RubyGems](https://rubygems.org/gems/pdf-forms) · [Docs](https://www.rubydoc.info/gems/pdf-forms/1.5.2)

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
- Capabilities: [From the pdf-forms docs](https://www.rubydoc.info/gems/pdf-forms/1.5.2)

```sh
gem install pdf-forms -v 1.5.2
```

**abntex/limarka** (446 stars)

[abntex/limarka](https://github.com/abntex/limarka) 

```ruby
def exporta
      configuracao_pdf  = "configuracao.pdf"
      configuracao_yaml = "configuracao.yaml"
      Dir.chdir(options[:input_dir]) do
        raise IOError, "Arquivo não encontrado: #{options[:input_dir]}/" + configuracao_pdf unless File.exist? (configuracao_pdf)
        pdf = PdfForms::Pdf.new configuracao_pdf, (PdfForms.new 'pdftk'), utf8_fields: true
        pdfconf = Limarka::Pdfconf.new(pdf: pdf)

        # exporta sem validação
        h = pdfconf.exporta(false)

        target_file = options[:output_dir]+'/'+configuracao_yaml
        puts "Sobrescrevendo #{target_file}".green if File.exist?(target_file)
        Limarka::Trabalho.save_yaml(h, target_file)
      end
    end
```

[lib/limarka/configuracao.rb](https://github.com/abntex/limarka/blob/95a786454f8e3db9db284ee9d4927a8c2c2f0aed/lib/limarka/configuracao.rb#L19-L34) · [More projects using pdf-forms →](https://dashboard.exa.ai/playground/search?q=pdf-forms%20GitHub%20projects)

**Quickstart**

```ruby
require "pdf_forms"

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

```

From [README.md](https://github.com/jkraemer/pdf-forms)

## FAQ

### Which Ruby PDF library should I use?

[Prawn](#prawn) suits PDFs drawn from Ruby with vector shapes, flowing text, and embedded fonts. [Wicked PDF](#wicked-pdf) suits PDFs rendered from HTML through wkhtmltopdf. [PDF::Reader](#pdf-reader) suits reading text and metadata from existing PDFs.

### What is Wicked PDF?

[Wicked PDF](#wicked-pdf) uses the wkhtmltopdf shell utility to serve a PDF file generated from HTML.

### Can Prawn convert HTML to PDF?

No. [Prawn](#prawn) cannot convert full HTML pages. Those need a browser renderer or an HTML-based tool such as [Wicked PDF](#wicked-pdf).

### How do I merge PDFs in Ruby?

[combine_pdf](#combinepdf) appends complete PDFs or selected pages. Its original maintenance has stopped.

### How do I fill PDF forms in Ruby?

[HexaPDF](#hexapdf) assigns values to AcroForm fields from a data hash. [pdf-forms](#pdf-forms) fills templates through the pdftk binary.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best Ruby PDF libraries Prawn HexaPDF CombinePDF PDF Reader code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
