Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To generate a PDF from an HTML view in Rails, render the view on the server and pass its HTML to a PDF engine. Two established approaches are Wicked PDF, which invokes the separate wkhtmltopdf executable, and Grover, which uses Puppeteer and Chromium. Choose based on the HTML/CSS your documents need and the runtime you can reliably install in production; then test assets, fonts, and pagination in the deployment environment itself.

Choose a PDF renderer for your Rails app

Both options turn HTML into a downloadable PDF, but they rely on different rendering stacks. Neither project documentation provides a controlled speed or fidelity comparison, so there is no evidence-based universal winner. Test representative documents in your actual production environment before committing.

Consideration Wicked PDF Grover
Rendering runtime Rails integration around the separate wkhtmltopdf command-line utility. Installing the gem alone does not install the executable. Project README Ruby interface to Puppeteer and Chromium. Plan for Node, Puppeteer, and a browser runtime in deployment. Project README
Input Can render Rails views to a PDF response and create PDFs from rendered HTML. Can convert HTML or a URL, and documents rendering Rails views.
Deployment question Can the compatible wkhtmltopdf binary be installed and reached by the app? Can Node, Puppeteer, and Chromium be installed and run in the target environment?
Performance and fidelity Not ranked here: available project documentation does not provide controlled comparative benchmarks. Measure output quality and resource use with your own templates and deployment setup.

Grover’s README includes Node and Puppeteer setup for Heroku as a platform-specific example, not a general deployment recipe. Check the current project documentation and your platform’s packaging guidance for runtime installation details.

Generate a PDF response with Wicked PDF

Install both the gem and the converter

Add the gem to your Gemfile and install it:

gem "wicked_pdf"
bundle install

Install a compatible wkhtmltopdf executable using the operating-system package or deployment method appropriate for your environment. The gem is a Rails integration, not the converter itself. If the executable is not on the application’s PATH, configure Wicked PDF with the executable path using the options documented by the project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

RubyGems records Wicked PDF 2.8.2 as released on October 26, 2024; that registry entry may not be the newest release when you install. Check the current version and compatibility with your Ruby and Rails versions at RubyGems, and consult the project README for configuration details.

Render a Rails view as a download

For example, a controller action can ask Rails to render a PDF format. Create a corresponding PDF template, such as app/views/invoices/show.pdf.erb, and use Wicked PDF’s render option:

class InvoicesController < ApplicationController
  def show
    @invoice = Invoice.find(params[:id])

    respond_to do |format|
      format.html
      format.pdf do
        render pdf: "invoice-#{@invoice.id}",
               template: "invoices/show",
               formats: [:html]
      end
    end
  end
end

The request can then target the PDF format, for example /invoices/42.pdf, subject to your routes and authorization. The template remains HTML/ERB; the converter produces the PDF response. Confirm the exact render options against the installed Wicked PDF version in its README.

You can also render HTML to a string and pass it to the converter when a view must be composed outside the normal response flow. This is useful for background jobs, but the HTML must still be available to the converter along with resolvable assets. The project README documents direct PDF creation from rendered HTML.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make stylesheets, images, and fonts resolvable

A PDF renderer runs outside the browser that served the Rails page. Relative asset paths that work in a browser may not resolve in the converter. Use absolute asset references or the integration’s asset helpers, and precompile any asset-pipeline files used by PDF views in production. Test image and stylesheet loading after deployment, not only in development. See the asset guidance in the Wicked PDF README.

Use a PDF-specific stylesheet when print layout differs from your web page. Keep critical styles straightforward, and verify page breaks, margins, and long tables with representative documents. A browser preview is not proof that the separate converter can fetch every resource or paginate it as intended.

Generate a PDF with Grover

Install the Ruby and browser runtimes

Add Grover to the Gemfile and install the bundle:

gem "grover"
bundle install

Then ensure the deployed application has the Node, Puppeteer, and Chromium runtime Grover needs. Installing the Ruby gem does not by itself settle browser provisioning. Grover’s README describes rendering Rails views and includes platform-specific installation examples; follow its current instructions for your host rather than assuming the Heroku example applies everywhere: Grover README.

RubyGems lists Grover 1.2.8 as released on February 11, 2026, with Ruby requirement >= 3.0.0, < 4.1.0. That is a version-specific registry record, not a promise that it is the newest version or compatible with every Rails release. Verify the installed version and runtime matrix at RubyGems and check the project’s current README.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Render a view string and convert it

One common pattern is to render the Rails template to an HTML string, then pass that string to Grover’s PDF method. The exact options and initialization can vary by version and app configuration, so use the API documented for the version in your bundle:

html = render_to_string(
  template: "invoices/show",
  formats: [:html],
  locals: { invoice: @invoice }
)

pdf = Grover.new(html).to_pdf
send_data pdf,
          filename: "invoice-#{@invoice.id}.pdf",
          type: "application/pdf",
          disposition: "attachment"

For example, this can run inside a controller action after loading an authorized invoice. If your template depends on request-specific URL helpers or assets, ensure it emits URLs the Chromium process can actually access. Grover also accepts a URL as input; a URL-based conversion requires the browser runtime to reach that URL. See its README for supported configuration and options.

Make assets, fonts, and pagination reliable

Check what the renderer can reach

  • Inspect the HTML generated by Rails, not just the source template. Confirm the expected stylesheet, image, and font URLs are present.
  • Use production-like absolute asset URLs or the renderer’s supported asset handling. Ensure assets are precompiled and accessible from the process performing conversion.
  • For URL-based rendering, check whether the converter can reach the hostname from its runtime environment, including authentication and network restrictions.
  • Test long and varied documents: multiple pages, large tables, missing optional fields, and images close to page boundaries.

Wait for fonts and verify output

Puppeteer’s PDF guide says Page.pdf() prints a page and waits for fonts to load by default. That makes font readiness worth checking when diagnosing layout changes, but it does not guarantee identical output across machines, operating systems, or browser versions. Confirm the produced PDF in the same environment and runtime versions you deploy. See the Puppeteer PDF guide.

Set and test page size, margins, orientation, and page-break behavior deliberately. A document that looks correct as a single browser page may paginate poorly when printed. Keep a small set of representative PDFs as regression checks when templates or runtime dependencies change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Secure the conversion path

Treat PDF generation as server-side content processing. An HTML renderer may fetch network resources or read local resources depending on configuration, so untrusted content can create security exposure.

  • Do not render unsanitized user-submitted HTML. Wicked PDF explicitly cautions against this.
  • Do not allow attacker-controlled URLs to cause requests to internal IP addresses or hostnames. Restrict destinations and network access for the conversion process.
  • Grover documents controls for local file and local network access; local file URI access is disabled by default. Enable sensitive access only where necessary and only with controlled inputs.
  • Keep user-provided values escaped in templates and avoid accepting arbitrary HTML, file paths, or resource URLs as conversion instructions.

Review the security guidance in the Wicked PDF README and the access controls in the Grover README.

Troubleshoot common PDF-generation failures

Symptom Likely cause What to check
Executable not found or conversion cannot start with Wicked PDF wkhtmltopdf is missing, incompatible, or not at the configured path. Install a compatible executable in the deployed image; confirm the app process can execute it; configure its path if it is outside PATH.
Grover fails to launch a browser Node, Puppeteer, or Chromium is missing or unavailable to the runtime user. Check the deployed runtime and permissions, then follow the current Grover/Puppeteer installation instructions for that platform.
PDF has missing CSS or images Relative URLs, uncompiled assets, inaccessible hosts, or authentication requirements. Inspect rendered HTML and emitted URLs; precompile assets; test reachability from the conversion process; use supported absolute URLs or helpers.
Fonts differ or text wraps unexpectedly The font file did not load, or runtime/browser differences changed metrics. Verify font URL accessibility and loading; compare runtime versions; inspect the generated PDF rather than relying on a browser preview.
Blank, truncated, or badly paginated pages Template output, timing, page dimensions, margins, or page-break behavior. Inspect the HTML, confirm the expected content is rendered, set page options deliberately, and test long representative documents in production-like conditions.
Conversion can access unexpected hosts or files Unrestricted URL input or sensitive local/network access settings. Restrict destinations and inputs; keep local-file access disabled unless required; do not accept unsanitized HTML or arbitrary URLs.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Plan for deployment, reliability, and cost

The primary operational cost is maintaining the converter runtime alongside Rails: an executable for Wicked PDF, or Node/Puppeteer/Chromium for Grover. Include installation in the deployment process, verify it after image or platform updates, and exercise PDF generation in a production-like environment. Browser and package requirements change, so pin and review compatible versions rather than treating a one-time setup as permanent.

PDF generation also consumes application resources. The cited project documentation does not establish comparative memory use, conversion speed, or concurrency limits for these approaches. Measure representative jobs on your own host, and consider moving heavy or bursty conversion work to background jobs so web requests are not held open. Set request or job timeouts and define how failed conversions are reported and retried in your application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

If your goal is a screenshot of a web page rather than a PDF generated from a Rails view, ScreenshotNeo is a website screenshot API and MCP server. It returns a PNG, JPEG, WebP, or PDF from a single GET request. For an API-generated PDF, set the format to PDF in the request parameters documented at ScreenshotNeo’s API documentation. Example screenshot request:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server gives AI agents tools for screenshots, page information, and PDF capture. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. It captures web pages, so it is not a substitute when you need Rails to render private application data directly from an HTML view.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Frequently Asked Questions

Can I generate a PDF without installing a converter runtime?

Not with the two Rails integrations covered here: Wicked PDF requires the wkhtmltopdf executable, while Grover requires a Puppeteer/Chromium runtime. A hosted screenshot or PDF API is a separate architecture.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does Grover support a URL as well as HTML?

Yes. Grover’s project documentation describes accepting HTML or a URL; ensure the browser runtime can reach the requested URL.

Will PDFs look identical in development and production?

Not necessarily. Asset access, installed fonts, operating system, and renderer versions can differ, so validate output in the deployment environment.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.