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

If wicked_pdf generates PDFs on your computer but fails on Heroku, first check whether the deployed app has the wkhtmltopdf executable. WickedPdf is a Ruby wrapper: it calls that separate command-line program to render HTML as a PDF. Your computer may already have the binary installed; a Heroku dyno is a different Linux environment and needs its own copy.

Choose one way to supply the binary—a Heroku buildpack or a Heroku-compatible gem—deploy it, verify the executable from a dyno, then configure WickedPdf to use the verified path if needed. If the command runs but the PDF lacks styling or images, investigate asset URLs separately; that is often a different problem from a missing executable.

Why WickedPdf can work locally and fail on Heroku

WickedPdf does not render a PDF entirely within Ruby. It invokes wkhtmltopdf, which turns HTML into a PDF. On a development machine, that program might be installed by the operating system or made available through a development dependency. Heroku builds and runs the app in its own Linux environment, so a binary present on your computer is not automatically present in the deployed app.

This distinction produces two broad classes of failure:

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.
  • The executable cannot be found or run: the binary was not included in the Heroku build, is not on the dyno’s PATH, or WickedPdf is looking at the wrong location.
  • The executable runs, but the PDF is incomplete: the HTML renderer cannot access the CSS, images, or other assets using the URLs or file paths supplied to it.

Diagnose those separately. Changing asset URLs will not install a missing binary, and changing the binary path will not make an inaccessible stylesheet load.

Choose how to provide wkhtmltopdf

Use one delivery method at a time so there is a clear answer to where the executable came from and which version is running.

Method Where the executable comes from Path and verification What to check
Heroku buildpack The buildpack copies the executable into the app slug during build. Verify the path in a dyno; some setups place it under bin/. Configure c.exe_path to that verified path if it is not found through PATH. Confirm the buildpack is attached and correctly ordered. Check its stack compatibility and version or download configuration.
Heroku-compatible gem, such as wkhtmltopdf-heroku The gem supplies or exposes a Heroku-compatible executable path. Inspect the gem’s installed path; the gem may expose it through Gem.bin_path. Do not assume a local executable or Bundler shim is available on the dyno. Check the Gemfile groups and lockfile, and confirm the gem is included in the deployed bundle.

A buildpack makes the binary’s inclusion a build concern; a gem makes its availability a dependency concern. Neither approach is universally preferable: choose based on your app’s stack compatibility, version-management needs, and the path you can verify in the deployed environment. Avoid installing both as a reflex; competing binaries can make it unclear which one WickedPdf invokes.

Install the binary and verify it on a dyno

  1. Choose and configure one delivery method. Attach a Heroku wkhtmltopdf buildpack or add a compatible gem to the appropriate Gemfile group, then commit the dependency changes if you use a gem. For a buildpack, confirm it appears in the app’s buildpack configuration and in the intended order relative to other buildpacks.
  2. Deploy the app. A local install or local test only confirms the binary works on your machine. It does not confirm that the Heroku build included it.
  3. Check for a PATH-visible executable. From a terminal with the Heroku CLI configured for the correct app, run heroku run which wkhtmltopdf, then heroku run wkhtmltopdf --version. These commands test the deployed dyno environment rather than your local shell.
  4. If it is not on PATH, test the installed absolute path. If the chosen buildpack put the binary at bin/wkhtmltopdf, for example, run heroku run bin/wkhtmltopdf -V. Use the actual path that exists in your slug, not an assumed path.
  5. Set WickedPdf’s executable path if necessary. Put the verified path in the initializer, then deploy again. The example below uses /app/bin/wkhtmltopdf only as an example; change it to the path verified in your dyno.

These checks establish whether the binary can be found and invoked. A successful version command does not by itself prove every PDF will render correctly, but it narrows an executable-installation failure from an asset or HTML-rendering failure.

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

Configure WickedPdf with the verified path

When the executable is not discoverable through the dyno’s PATH, configure its location explicitly in config/initializers/wicked_pdf.rb:

WickedPdf.configure do |c|
  c.exe_path = '/app/bin/wkhtmltopdf' # replace with the path verified in the dyno
  c.enable_local_file_access = true   # needed when local files are read with wkhtmltopdf > 0.12.6
end

exe_path tells WickedPdf which command to run. Do not copy the example path unchanged unless you have verified that the executable is there. A path that works on a laptop, such as one under a package-manager directory, is unlikely to be the right path in a Heroku slug.

enable_local_file_access is relevant when the renderer needs to read local files and the deployed wkhtmltopdf version is newer than 0.12.6. It is not a substitute for using reachable asset URLs, nor does it install the executable. Only enable the setting when the PDF needs local-file access; verify that this matches your asset approach and renderer version.

Fix missing CSS and images after the command works

wkhtmltopdf runs as an external program, not as a browser tab inside the Rails process. Relative paths that resolve during local development may not resolve from the renderer’s context on a dyno. If the PDF is created but appears unstyled or omits images, inspect the URLs and paths passed into the HTML.

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

Use absolute URLs for assets served by the app

Where assets are served over HTTP, provide absolute URLs that the renderer can reach, including the correct scheme and host. Check that the production asset host or relevant Rails configuration is set as intended. A relative URL such as /assets/application.css may not be enough if the renderer has no usable base URL for it.

Use WickedPdf asset helpers where appropriate

WickedPdf provides asset helpers for generating asset references in PDF templates. Use those helpers where they fit your Rails asset setup, and inspect the resulting HTML or URL when an asset is missing. A helper can construct the reference, but the asset still has to be available in the deployed environment.

Use local files only when the renderer can access them

If the PDF references files on disk rather than assets served over HTTP, confirm the path exists inside the dyno and that the renderer is allowed to read it. For local-file reads with versions of wkhtmltopdf newer than 0.12.6, configure local-file access as shown above. A path on your development machine does not exist on Heroku merely because the application code refers to it.

Compare local and deployed asset configuration

Heroku Local reads configuration from a local .env file, while deployed config vars are managed by Heroku. A local asset host or base URL can therefore differ from the deployed value. Compare the relevant local and deployed settings rather than assuming the generated HTML is identical in both environments.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common Heroku failures

Symptom Likely cause What to do
wkhtmltopdf: command not found or no output from which The binary is missing, not on PATH, or installed at a different location. Confirm the buildpack or gem is included in the deployment. Test the binary by its verified absolute path and set c.exe_path to that path if needed.
The version command works on a laptop but not through heroku run The local executable is not part of the Heroku slug. Install it through the chosen Heroku delivery method, redeploy, and repeat the dyno-side version check.
Bundler reports that wkhtmltopdf-binary is not in the bundle The gem shim may be excluded from the deployed bundle or absent from the relevant Gemfile group or lockfile. Inspect the Gemfile groups and lockfile. Confirm the dependency is installed in the production deployment; do not assume a system binary makes an excluded gem shim usable.
The buildpack is configured, but the executable is still absent or stale The buildpack may not be attached or correctly ordered, may not support the app’s stack, or an old build cache may retain an earlier binary. Confirm buildpack attachment and order, check stack compatibility, and clear the Heroku build cache before redeploying after a version or download-URL change.
The PDF renders, but styles or images are missing The renderer cannot resolve relative URLs, reach an asset host, or read local files. Use absolute reachable URLs or suitable WickedPdf asset helpers. Check production asset-host settings and enable local-file access only if the PDF needs local files.
The app’s local and deployed PDFs differ Environment configuration, especially the asset host or URL, can differ between Heroku Local and the deployed app. Compare local .env values with the deployed Heroku config vars used to construct PDF asset references.

Redeploy cleanly when the binary changes

If you change a buildpack’s download URL or binary version and a deployment still appears to use the previous executable, clear the Heroku build cache and redeploy. A buildpack’s cached repository contents can otherwise preserve an older binary. After the new build, repeat the version check inside a dyno so you know which executable the deployed app is actually using.

Also check the Heroku stack before selecting a buildpack. Older buildpacks can have stack limitations, and a buildpack that does not support the app’s stack will not become compatible simply because the local version works.

Keep PDF rendering reliable and costs predictable

  • Pin and verify the executable intentionally. Know whether the buildpack or gem supplies it, and verify the version after changes. A successful build alone does not tell you which binary WickedPdf will execute.
  • Test a representative PDF on Heroku. Include the kinds of production assets your templates use—such as stylesheets and images—so a test covers more than binary availability.
  • Separate operational checks. Confirm executable visibility, then render a PDF, then check the PDF’s assets. This makes failures easier to isolate than changing the binary, initializer, and template at once.
  • Account for runtime and deployment behavior. PDF generation consumes dyno resources and depends on the renderer completing its work. This establishes no universal timeout, memory requirement, or rendering-speed figure, so measure your own templates and workload rather than relying on a generic numeric target.
  • Review the exact buildpack and stack combination. Compatibility and binary-download behavior can change with the selected buildpack and configuration. Verify the details for the one your app uses before changing versions.

Or skip the browser setup

If your goal is to capture a web page as an image or PDF rather than generate your Rails app’s own WickedPdf document, ScreenshotNeo offers a one-request screenshot API. It is not a fix for a missing wkhtmltopdf binary and does not replace a custom Rails PDF workflow; it is an alternative for capturing a URL.

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

See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots, and the Free plan includes 1,000 shots per month with no card required; paid plans start at $5 for 3,000 shots. Sign up for free.

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.

Frequently Asked Questions

Does installing WickedPdf also install wkhtmltopdf?

No. WickedPdf invokes the separate command-line executable; ensure your chosen Heroku build method supplies it.

Should I set exe_path to /app/bin/wkhtmltopdf?

Only if that is the path verified in your deployed dyno. The example path is not universal.

Can ScreenshotNeo repair a failing WickedPdf deployment?

No. It captures a URL through its screenshot API; it does not install or configure wkhtmltopdf for a Rails app.

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.