Recommended Free Tools
For a Ruby application, Grover is a direct way to convert a webpage URL to PDF: install the gem and its documented Puppeteer dependency, then call Grover.new(url, format: 'A4').to_pdf. Grover uses Puppeteer and Chromium, so deployment requires a browser runtime as well as Ruby code. If you are maintaining an older application, PDFKit and Wicked PDF are alternatives built around wkhtmltopdf, but that upstream project has been archived.
Convert a URL to PDF with Grover
Grover provides a Ruby interface to Puppeteer and Chromium. Its documented URL workflow creates a Grover instance with the page address and PDF options, then calls to_pdf. The method returns PDF data, which you can write to a file or return from a web application.
Install the Ruby gem and browser dependency
Add Grover to your Gemfile:
# Gemfile
gem 'grover'
Install the gem with Bundler, and install Puppeteer as Grover’s project documentation instructs:
bundle install
npm install puppeteer
Make sure the deployed application can access the corresponding Puppeteer/Chromium runtime. Installing only the Ruby gem is not the whole deployment: the browser process is what loads and renders the webpage. The precise runtime setup can differ by deployment platform and installed versions, so check Grover’s documentation and your platform’s browser requirements when packaging the app.
#1 Best Overall
Generate and save a PDF from a URL
require 'grover'
url = 'https://example.com'
pdf = Grover.new(url, format: 'A4').to_pdf
File.binwrite('page.pdf', pdf)
The format: 'A4' option requests an A4 page size. Grover documents to_pdf as returning inline PDF data; File.binwrite saves those bytes without treating them as text. Replace the example URL with the page you need to capture and choose PDF page options to match the intended output. Grover exposes Puppeteer PDF options through its wrapper; check the option names against the Grover version installed in your project rather than assuming every Puppeteer option maps identically.
Return the PDF from Rails
For a Rails view, Grover’s documented pattern is to render the view to a string and pass that HTML to Grover. For example, inside a controller action:
html = render_to_string(
template: 'reports/show',
layout: 'report'
)
pdf = Grover.new(html, format: 'A4').to_pdf
send_data pdf,
filename: 'report.pdf',
type: 'application/pdf',
disposition: 'inline'
Use the template and layout names from your application. If users should download the result rather than view it in the browser, change the disposition to an attachment. The rendered HTML must include or be able to resolve the CSS, images, and fonts needed for the document.
Make the PDF match the page you intend to print
A PDF is a print rendering, not necessarily a pixel-for-pixel copy of the browser viewport. Page size, margins, print styles, asset URLs, and when the page is considered ready can all affect the result.
Rank #2
Print styles versus screen styles
Puppeteer’s PDF generation uses the print media type by default and waits for fonts to load. A site may therefore hide navigation, change colors, or rearrange content for print. If the PDF should follow the site’s screen styles instead, Puppeteer documents emulating the screen media type before generating the PDF. Grover wraps Puppeteer; verify how to set media emulation with the exact Grover version you use.
Relative CSS and image paths
When Grover receives raw HTML, relative references need a base address. Grover documents a display_url option for this case; otherwise Chromium resolves relative paths against the display URL host, which defaults to http://example.com for raw HTML. Set a suitable display URL or convert relative references to absolute URLs before rendering. A URL-based capture already has a page address from which the browser can resolve that page’s relative resources.
Choose page options deliberately
- Paper size: Select the format appropriate to the document, such as A4, rather than relying on an unsuitable default.
- Margins: Set them to preserve readable content and avoid clipping at the page edges.
- Print or screen appearance: Decide whether the document should follow print-specific layout or screen styling.
- Headers, footers, and page layout: Confirm the installed Grover version’s supported Puppeteer PDF options before relying on a specific option name or behavior.
The available documentation establishes the general controls but does not provide a controlled comparison of rendering fidelity, speed, or memory use across engines. Test representative pages in the deployment environment before selecting settings for a production workflow.
Choose between Ruby PDF libraries
The right option depends on whether you want a current browser-based rendering path, need to preserve an existing Rails integration, or already operate a wkhtmltopdf executable. These tools are not interchangeable in deployment requirements.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallRank #3
| Option | Rendering approach | Best fit and trade-off |
|---|---|---|
| Grover | Ruby interface to Puppeteer and Chromium | Accepts a URL or HTML and returns PDF output. Requires Puppeteer and a browser runtime in addition to the gem. |
| PDFKit | Ruby wrapper around the wkhtmltopdf executable |
Accepts a URL, HTML, or file. The executable must be installed and discoverable or configured. Upstream wkhtmltopdf is archived. |
| Wicked PDF | Rails integration that renders HTML and invokes wkhtmltopdf |
Useful in Rails-oriented workflows, but it shares the archived executable dependency. Asset references need to be reachable outside the Rails process. |
| FerrumPdf | Ruby project documenting PDF creation from a URL or HTML | Worth evaluating if its browser integration suits your app. The available evidence does not establish superior compatibility, maintenance, or performance. |
No controlled benchmark establishes a universal fastest or most faithful choice. Compare the page behavior you need, the runtime you can deploy, how your app resolves assets and authentication, the project’s maintenance status, and required PDF layout options.
PDFKit and Wicked PDF for existing applications
PDFKit URL conversion
PDFKit documents both returning PDF bytes and writing output to a file:
require 'pdfkit'
kit = PDFKit.new('https://example.com')
pdf = kit.to_pdf
File.binwrite('page.pdf', pdf)
# Or write directly to a file:
PDFKit.new('https://example.com').to_file('page.pdf')
PDFKit depends on the wkhtmltopdf command-line executable. Install that executable separately and configure its path if it is not found automatically; adding the gem alone is insufficient. For HTML with relative assets, PDFKit documents root_url or protocol options to help resolve them. Its documentation notes that stylesheets cannot be added in the same way when the source is a URL or file.
Wicked PDF in Rails
Wicked PDF adds Rails conventions around rendering HTML and calling wkhtmltopdf. Its README cautions that the executable runs outside the Rails application, so CSS, JavaScript, and image references need to be available as absolute references. This matters when assets that work inside a Rails view are not accessible to the separate PDF process.
Rank #4
The wkhtmltopdf repository was archived on January 2, 2023 and is read-only. That status is a maintenance consideration for new projects; it does not mean existing installations automatically stop working. If your application already relies on PDFKit or Wicked PDF, assess the dependency and test it on your target platform rather than assuming it must be removed immediately.
Handle common conversion failures
- The Ruby code cannot find a browser: The Gemfile dependency does not install every runtime component. Confirm Puppeteer is installed as documented and that Chromium is available to the deployed application.
- PDFKit reports that wkhtmltopdf is missing: Install the executable separately, then ensure it is discoverable or configure the executable path for PDFKit.
- Images or styles are missing from raw HTML: Relative paths need a base. Set Grover’s
display_urlor use absolute asset paths. For PDFKit HTML, use its documentedroot_urlorprotocoloptions where appropriate. - Rails assets work in the page but not the PDF: With Wicked PDF, the renderer runs outside the Rails application. Use absolute, reachable asset references rather than paths that only make sense inside the application.
- The PDF looks different from the browser: Check whether print media styles are being applied. Puppeteer uses print media by default; screen-style output requires screen media emulation before PDF generation.
- Text or layout differs around fonts: Puppeteer PDF generation waits for fonts to load, but the page still needs to make its fonts available. Check the rendered page’s asset references and the PDF options supported by your installed wrapper version.
For failures that depend on a particular site, distinguish a browser/runtime problem from a page problem: confirm that the URL is reachable by the application environment, that its assets resolve there, and that the chosen rendering engine supports the behavior your page relies on. The available project documentation does not establish cross-site reliability or comparative performance figures.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If you only need a PDF or screenshot of a public webpage and do not need the browser process inside your Ruby deployment, ScreenshotNeo offers a website screenshot API that can return a PNG, JPEG, WebP, or PDF. Its API is a one-request alternative to setting up browser rendering locally. The example below uses the documented WebP output shape; consult the ScreenshotNeo API documentation for the PDF response option before using it for PDF output.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
ScreenshotNeo accepts cookie or consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. It also provides an MCP server with screenshot, page-information, and PDF-capture tools for AI agents. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteSign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Best Value
FAQ
Does Grover return a file path or PDF data?
Its documented to_pdf method returns inline PDF data. Write those bytes to a file or pass them to your Rails response.
Can I convert HTML instead of a live URL?
Yes. Grover accepts HTML; when it contains relative asset references, provide a suitable display URL or make the paths absolute.
Is wkhtmltopdf still maintained?
Its GitHub repository has been archived and is read-only since January 2, 2023. Existing installations may still run, but new projects should account for that upstream maintenance status.
Quick Recap
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.

