October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Asset Pipeline

Why wicked_pdf CSS and Assets Disappear in Production

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

If a Rails page looks correct in development but its wicked_pdf PDF loses CSS, scripts, or images, start with the production asset path: identify the app’s asset system, confirm the PDF assets are included in the production build, and check that the URLs in the generated HTML are reachable by the process running wkhtmltopdf. A browser-rendered Rails page and a PDF renderer do not necessarily resolve assets in the same environment.

There is no single root cause established by the title alone. The right fix depends on the Rails and wicked_pdf versions, whether the app uses Sprockets, Propshaft, Webpacker, or another bundler, and what HTML and URLs the renderer actually receives.

Why can wicked_pdf work in development but fail in production?

Development and production can differ in how assets are built, named, served, and accessed. A development page may load an asset through a development server or an un-fingerprinted path. A production build may instead require precompiled files with digest-based names, or may emit URLs that the PDF process cannot fetch.

The wicked_pdf project specifically warns that assets can behave differently between development and production and recommends precompiling assets used by PDF views. That is a useful first check, not proof that every missing-style problem is caused by precompilation. The issue may instead be a helper that does not match the app’s asset integration, a bad URL, or a renderer access limitation. See the wicked_pdf README.

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

Keep the distinction clear: the Rails page being styled in a browser proves that the browser got its assets under its own conditions. It does not prove the generated PDF HTML contains the same references or that wkhtmltopdf can retrieve them.

Identify the asset system before changing helpers

First establish how this application manages assets. Do not copy a configuration snippet from an older Rails or wicked_pdf setup until you know which integration the deployed app uses.

Asset setup What to verify Relevant guidance
Sprockets or another asset-pipeline setup Use the wicked_pdf asset-pipeline helpers where appropriate and ensure PDF-view assets are part of production precompilation. wicked_pdf README
Propshaft Check the current app’s manifest and deployed output. Rails documents production precompilation into public/assets and digest-based names, with logical paths resolved through the manifest. Rails Asset Pipeline guide and Propshaft documentation
Existing Webpacker setup Use the pack helpers documented by wicked_pdf only if this app actually uses Webpacker and its generated packs are available in production. wicked_pdf README
Another bundler or custom delivery path Determine how that setup builds and serves the exact files referenced by the PDF HTML; do not assume a Sprockets or Webpacker helper applies. Check documentation for the installed integration and versions.

Current Rails documentation describes Propshaft as the default for new Rails applications; that does not mean every existing app uses it. The Rails guide also notes that other tools may handle bundling or transpilation. Webpacker-specific guidance is relevant to apps that still use it, but the Rails guide identifies Webpacker as retired. Match instructions to the application rather than treating any one setup as universal. See the current Rails asset-pipeline guide and the Rails 7.2 guide.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Check whether production actually built the PDF assets

For asset-pipeline assets referenced by a PDF view, verify that the relevant stylesheets, scripts, and images are included in the production precompile process as appropriate for the app’s Rails version. Then inspect the deployed artifact—not just local development—to confirm the files exist where the production manifest and server expect them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Identify the exact PDF view assets. List the stylesheet, JavaScript, fonts, and image files the view refers to. Include assets loaded indirectly by CSS, such as background images or fonts.
  2. Check the production build configuration. Confirm that assets used only by PDF views are included in precompilation if the app’s integration requires it. Follow the version-matched Rails and asset-system documentation.
  3. Inspect deployed output and manifest. For Propshaft, Rails documents precompiling into public/assets and digest-stamped filenames; verify the logical-to-digested mapping and that deployment includes the output.
  4. Read the production error, if any. Rails 7.2 documentation says a missing precompiled asset can raise AssetNotPrecompiledError. Treat that as a distinct clue from HTML that renders successfully but points to an unavailable URL.

Do not blindly add old Sprockets configuration to a Propshaft app or assume a logical filename is also the final deployed filename. The Rails 7.2 asset guide describes the missing-precompiled-asset error; current behavior should be checked against the guide matching the app’s installed Rails generation.

Use helpers that match the integration

The wicked_pdf README documents asset-pipeline helper methods including wicked_pdf_stylesheet_link_tag, wicked_pdf_javascript_include_tag, and wicked_pdf_image_tag. It also documents Webpacker-specific methods: wicked_pdf_stylesheet_pack_tag, wicked_pdf_javascript_pack_tag, and wicked_pdf_asset_pack_path.

Those are integration-dependent examples, not interchangeable spellings. Choose the helper family that corresponds to the asset system actually installed and configured. If an app has moved away from Webpacker or uses a different pipeline, first establish the supported reference method for its current setup rather than copying a pack helper because it appears in an older PDF view.

The README also shows using a CDN for libraries. That can make an asset available by an external URL, but only if the renderer can reach that host under the deployment’s network and access conditions. A CDN reference does not fix an incorrect URL or an unavailable network path.

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

Verify the URLs in the HTML wkhtmltopdf receives

Once the build looks right, inspect the HTML produced for the PDF and record the exact URL for each missing asset. Check the URL from the environment running the PDF generation—not merely from your laptop’s browser.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
  • Is it a valid path? Look for misspellings, wrong relative paths, stale asset names, and references that omit a deployment prefix or host.
  • Does it resolve to the production asset? Digest-based builds can make the final filename differ from the logical asset name. Confirm that helpers or manifests translate correctly.
  • Can the renderer reach it? Consider hostnames, credentials, network rules, TLS, and whether the URL is internal or public. The evidence needed is the actual URL and renderer context, not the browser’s success.
  • Does one broken image coincide with other missing images? The wicked_pdf README notes that a wrong image path may affect other images in wkhtmltopdf output. Treat this as a documented edge case to test, not a universal explanation for missing assets.

The README also documents local-file behavior involving show_as_html: wicked_pdf helpers may use file:/// paths, and browser cross-domain safety can prevent rendering in that mode. If the output differs when using show_as_html, inspect those generated paths and the display context before concluding that production precompilation is at fault. See the wicked_pdf README copy.

Choose external URLs or base64 embedding deliberately

External asset URLs keep HTML references separate from asset content, but depend on correct paths and renderer access. The wicked_pdf README documents wicked_pdf_asset_base64 as a workaround for some asset-pipeline helper issues: it embeds content into the page rather than asking the renderer to fetch a separate asset URL.

Embedding is not automatically better. The README warns that base64 embedding can take a long time for large assets. It may help isolate a URL or helper problem for selected assets, but it increases the content carried in the HTML. Compare the delivery choices against the assets involved:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Delivery form Potential advantage Trade-off to check
Asset-pipeline helper and external reference Uses the application’s configured asset mapping and keeps asset data outside the HTML. Precompilation, manifest resolution, and renderer URL access must all be correct.
CDN URL References an asset through a separately served URL. The rendering process still needs to reach the CDN and receive the intended file.
Base64 embedding Places asset content inline and can work around some helper issues. Large embedded assets may take longer, according to the wicked_pdf README.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

A production debugging sequence

  1. Record versions and integration. Note the Rails and wicked_pdf versions and identify Sprockets, Propshaft, Webpacker, or another asset system.
  2. Capture the failing evidence. Save the generated PDF HTML, exact missing-asset URLs, relevant production build output, and wkhtmltopdf logs. Avoid changing several variables at once.
  3. Separate build failures from fetch failures. If the build reports a missing precompiled asset, address precompilation and manifest resolution. If HTML contains a plausible URL, test whether the PDF process can retrieve that exact URL.
  4. Confirm helper alignment. Replace mismatched helper usage with the method documented for the installed integration, then regenerate the HTML and inspect the resulting references.
  5. Test a controlled alternative where appropriate. For one affected asset, compare the normal helper reference with a reachable CDN URL or documented base64 embedding. Note whether the result isolates a path problem or changes the failure.
  6. Retest from the deployed environment. A local development success does not establish that production deployment output, network access, or renderer behavior is correct.

Common symptoms and fixes

Symptom Likely diagnostic branch Next action
Rails raises AssetNotPrecompiledError The requested asset is absent from the precompiled set for the relevant Rails setup. Check PDF-view assets in production precompilation and confirm the deployment includes the resulting files and manifest.
PDF HTML has an asset URL, but the PDF omits the file The path may be wrong, stale, inaccessible, or blocked from the renderer’s runtime context. Test the exact URL from the PDF generation environment and inspect host, path, access, and network configuration.
Styles work in browser preview but not PDF The browser and PDF renderer may resolve different URL forms or run under different access conditions. Inspect the generated PDF HTML, including stylesheet links and CSS-referenced assets; verify each reference as the renderer sees it.
One bad image seems to affect other images The README documents a possible wkhtmltopdf image-loading issue when one image path is wrong. Verify every image path, correct the invalid one, and retest; do not assume this explains unrelated CSS or script failures.
Local-file preview behaves differently with show_as_html Local file:/// references and browser cross-domain safety may affect the preview. Inspect the path and preview context separately from production PDF generation.

What evidence is needed to name the root cause?

A defensible diagnosis needs the Rails and gem versions, asset system, generated PDF HTML, asset URLs, deployed build artifact, and renderer logs. Without those, claims such as “Rails 7 broke wicked_pdf” or “this is always a missing precompile entry” overstate what the symptom establishes.

For a browser-facing sanity check, a screenshot can show whether a normal web page’s visible result is correct; it cannot prove that wkhtmltopdf can retrieve the same assets or that its PDF rendering will match. ScreenshotNeo is a website screenshot API and MCP server, not a Rails asset-pipeline or PDF-renderer fix.

Or skip the browser setup

For a quick screenshot of a deployed page while you separately investigate the PDF process, ScreenshotNeo accepts a URL in one GET request and returns an image or PDF. Its documentation describes the API. Example cURL request:

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

Python and Node.js equivalents:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://example.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
  • Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; each of those steps can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers report the page verdict and billing status.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.
  • The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. All features are on every plan.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

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

Frequently Asked Questions

Does a screenshot of the Rails page prove the PDF will render its CSS?

No. A screenshot checks a browser-facing page; it does not establish that wkhtmltopdf can access the PDF HTML’s asset URLs or render them the same way.

Should I switch every wicked_pdf view to base64 assets?

No. The project documents base64 as a workaround for some helper issues and warns that large embedded assets may take longer. Use it selectively after checking paths and renderer access.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.