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

To turn a Rails invoice into a downloadable PDF, render its HTML template with render_to_string, pass the resulting HTML to a PDF renderer, and send the returned bytes with a PDF content type and filename. Grover uses Puppeteer and Chromium; Wicked PDF and PDFKit use wkhtmltopdf. The right choice depends on your app’s runtime and the invoice’s CSS, JavaScript, and asset requirements.

Choose a renderer for your invoice

Option Rendering engine Best fit and considerations
Grover Puppeteer and Chromium A candidate when the invoice relies on browser behavior or modern web styling. Deployment must include the required Node.js/Puppeteer/Chromium runtime. Its README documents Rails template rendering with render_to_string. Grover documentation
Wicked PDF wkhtmltopdf, invoked as a shell utility Offers Rails controller integration and methods to render a string or save bytes. The README lists Ruby 2.2–3.2 and Rails 4–7.0 as verified; check the exact gem release before relying on those compatibility statements. Wicked PDF documentation
PDFKit wkhtmltopdf A Ruby wrapper with HTML conversion and Rails/Rack middleware options. Its README lists Ruby 2.5–3.1 and Rails 4.2, 5.2, and 6.0–7.0 as supported; confirm those claims against the release you choose. PDFKit documentation

These project documents do not provide a controlled performance comparison or a direct feature test across all three libraries. Do not choose based on an assumed speed advantage: test your invoice’s layout, assets, and deployment environment with the renderer you plan to run.

Build a Rails invoice PDF with Grover

Install the Ruby gem and browser dependencies

Grover’s documented setup uses the grover gem and Puppeteer’s npm package. Add the gem to your Gemfile and install it:

gem "grover"
bundle install

Install the Puppeteer package using the package manager and lockfile workflow already used by your application. Your production environment must also be able to run the browser runtime; verify that Chromium can launch there rather than assuming a local development setup will behave the same way.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Render the invoice template and return a PDF

Keep invoice markup in a dedicated Rails view so it can be reviewed and styled as HTML. For example, create app/views/invoices/show.pdf.erb or a dedicated HTML partial, and render it with the invoice record available to the template. A controller action can then render the HTML to a string and pass it to Grover:

class InvoicesController < ApplicationController
  def download
    @invoice = current_user.invoices.find(params[:id])

    html = render_to_string(
      template: "invoices/show",
      formats: [:html],
      layout: "invoice"
    )

    pdf = Grover.new(html).to_pdf

    send_data pdf,
      filename: "invoice-#{@invoice.id}.pdf",
      type: "application/pdf",
      disposition: "attachment"
  end
end

Use the authorization and record lookup appropriate to your application; the example scopes the invoice to the current user. Keep the view’s data requirements explicit so rendering it for a PDF does not depend on state that exists only during an ordinary browser request.

Make relative assets resolvable

When Grover receives HTML directly, relative paths need a base URL. Its README documents a display_url option; absent a configured display URL, its documented default is http://example.com. You can supply the application origin so paths resolve against the intended host:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
pdf = Grover.new(
  html,
  display_url: "https://app.example.com"
).to_pdf

Alternatively, generate absolute asset URLs in the HTML. Ensure that the browser process can reach any URL it needs, including authenticated assets, and avoid depending on a developer-only hostname or credentials.

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.

Use Wicked PDF or PDFKit instead

Wicked PDF controller response

Wicked PDF integrates with Rails’ response formats. After installing the gem and the wkhtmltopdf executable, a controller can respond to a PDF request:

def download
  @invoice = current_user.invoices.find(params[:id])

  respond_to do |format|
    format.pdf do
      render pdf: "invoice-#{@invoice.id}",
        template: "invoices/show.pdf.erb",
        disposition: "attachment"
    end
  end
end

Use the option names and template conventions supported by the exact Wicked PDF release in your application. The project README also documents rendering to a string and saving PDF bytes when a direct Rails response is not the right fit. Because wkhtmltopdf runs outside the Rails process, give it absolute references to stylesheets, JavaScript, and images that it must load. See the Wicked PDF README for installation and integration details.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

PDFKit conversion

PDFKit wraps wkhtmltopdf and documents creating a PDF from HTML, as well as Rails and Rack middleware setups. For raw HTML conversion, its README says to use complete file paths or URLs. It recommends hand-installing wkhtmltopdf and also points to a binary gem as an alternative. Check the instructions for the release and deployment platform you select: a Ruby wrapper alone does not ensure the external executable is installed. See PDFKit’s README.

Check print styling and invoice correctness

PDF generation is a print-rendering task, not simply a screenshot of the current browser viewport. Puppeteer’s Page.pdf documentation says PDF generation uses print media by default; if you need screen media styles instead, it directs users to emulate screen media before calling page.pdf(). Puppeteer Page.pdf API.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Use print CSS for page breaks, margins, colors, and elements that should not appear on paper.
  • Test long descriptions, multiple line items, multi-page invoices, and totals near a page boundary.
  • Check page size, orientation, currency and date formatting, Unicode characters, logos, and font loading.
  • Verify the rendered PDF in the deployed environment with representative invoices; a successful local render does not establish that production assets or fonts are reachable.

Handle assets and deployment deliberately

All renderer choices need a reliable route to the invoice’s images and styles. With direct HTML input, relative URLs can resolve against an unexpected base; with wkhtmltopdf, the renderer runs separately from Rails and must be able to access the references. Decide whether assets will be absolute public URLs, local complete paths, or provided through the renderer’s documented configuration, then test that exact approach in production.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Grover adds Puppeteer and Chromium to the runtime requirements. Wicked PDF and PDFKit require the wkhtmltopdf executable. These deployment dependencies affect packaging and operations; none of the cited project documents establishes a universal performance or resource-cost winner.

Protect the renderer from untrusted content

Do not treat arbitrary HTML or remote asset URLs as harmless just because the result is a PDF. Wicked PDF warns that user-provided page content can request internal IP addresses or hostnames, including cloud metadata endpoints. Sanitize untrusted markup and restrict the renderer’s network access to destinations it actually needs. Apply equivalent input and network controls to any renderer that loads URLs or resources on the server.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common PDF failures

  • The app cannot find or launch the renderer: confirm the selected gem is installed and that the matching runtime is available in the deployed environment—Puppeteer/Chromium for Grover or the wkhtmltopdf executable for Wicked PDF and PDFKit.
  • The PDF has missing CSS, images, or fonts: inspect the generated HTML for relative URLs, set Grover’s display URL or use absolute references, and confirm the renderer process can reach each asset.
  • Styles differ from the web page: inspect print-specific CSS and test the PDF renderer directly. For Puppeteer, remember PDF generation uses print media by default unless screen media is explicitly emulated.
  • Content is clipped or split awkwardly: reproduce with long descriptions and multi-page invoices, then adjust print CSS, page breaks, and page settings for that renderer.
  • Rendering hangs or reaches internal services unexpectedly: review remote resources referenced by the HTML, impose appropriate execution and network boundaries, and do not allow untrusted invoice markup to fetch arbitrary destinations.
  • A setup that worked locally fails after deployment: compare installed binary/browser versions, operating-system libraries, asset URLs, and runtime permissions between environments.

Or skip the browser setup

If your task is to capture a rendered invoice page rather than generate a paginated invoice PDF, ScreenshotNeo provides a screenshot API and MCP server. A single GET request can return an image or PDF; use the documented PDF options when you need a document rather than a page capture. Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; bot checks, blank pages, failed loads, and cache hits are not billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots. See ScreenshotNeo and the API documentation.

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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://your-app.example.com/invoices/123.pdf -o invoice.pdf

This is a page-capture alternative, not a replacement for Rails’ invoice rendering and authorization logic. The page must be accessible to the capture service, and the API key should be kept server-side. Sign up for 1,000 free screenshots a month with no card.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Frequently Asked Questions

Does Rails itself convert an HTML view into a PDF?

No. Rails can render the view to HTML, but a separate renderer such as Grover, Wicked PDF, or PDFKit must produce the PDF bytes.

Can I use the same invoice template for browser display and PDF output?

Yes, but give it print styles and test pagination and asset loading in the chosen renderer; browser display alone does not guarantee identical PDF output.

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.

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