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

The dependable fix is to stop relying on stdin to supply a directory base. When you pipe HTML into wkhtmltopdf -, relative references such as css/style.css may be resolved from an unexpected location. In a documented case, the stylesheet became file:///tmp/style.css even though converting the same HTML file by name worked.

Use a named HTML file in the directory that contains its assets, or change every local reference to an explicit path or reachable URL. Then check local-file permissions separately. The permission switches can allow a file to be read, but they do not give a stdin stream the original file’s directory as its base.

What “redirected streams” means in this wkhtmltopdf problem

Here, a redirected stream is shell input such as cat page.html | wkhtmltopdf - out.pdf or wkhtmltopdf - out.pdf < page.html. The first hyphen tells wkhtmltopdf to read HTML from standard input; the output filename tells it where to write the PDF. The libwkhtmltox settings documentation also defines - as stdin for input and stdout for output when used in those positions (settings documentation).

A stream contains bytes, not the source file’s pathname and parent directory. Therefore, a relative URL in the HTML may not resolve beside the file you originally read. This is a reported behavior, not a guarantee that every binary and operating system fails in exactly the same way.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
  • EDIT text, images & designs in PDF documents. ORGANIZE PDFs. Convert PDFs to Word, Excel & ePub.
  • READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.
  • CREATE, COMBINE, SCAN and COMPRESS PDFs
  • FILL forms & Digitally Sign PDFs. PROTECT and Encrypt PDFs
  • LIFETIME License for 1 Windows PC or Laptop. 5GB MobiDrive Cloud Storage Included.

Reproduce the difference before changing your build

  1. Record the binary and environment:
    wkhtmltopdf --version
    uname -a
    pwd

    On Windows, record the Windows edition and the directory from which the command is run instead.

  2. Create a minimal tree:
    sample/
    ├── page.html
    └── css/
        └── style.css
  3. Use identical HTML and assets for both tests. For example, page.html can contain <link rel="stylesheet" href="css/style.css">.
  4. Convert by filename:
    cd sample
    wkhtmltopdf page.html named.pdf
  5. Convert the same bytes through stdin and save all diagnostics:
    cat page.html | wkhtmltopdf - piped.pdf 2>stdin-warnings.txt
  6. Compare the PDFs and read the complete warning file. In issue 3627, the named-file conversion loaded the relative stylesheet while the piped conversion warned about file:///tmp/style.css (reported issue, opened September 1, 2017).

If both forms fail, the problem is probably not the stdin base alone. Check the HTML, asset spelling, permissions, and the installed binary. If only stdin fails, use one of the workflows below.

Fix 1: convert a named HTML file

This is the closest match to the workflow that succeeded in the reported case. Keep the HTML and relative assets in their intended directory and pass the filename directly:

wkhtmltopdf /srv/site/page.html /srv/output/page.pdf

If the document is generated dynamically, write it to a controlled temporary directory together with the asset tree, then invoke wkhtmltopdf with that filename:

tmpdir=$(mktemp -d)
mkdir -p "$tmpdir/css"
printf '%sn' '<link rel="stylesheet" href="css/style.css"><h1>Invoice</h1>' > "$tmpdir/page.html"
cp /srv/site/css/style.css "$tmpdir/css/style.css"
wkhtmltopdf "$tmpdir/page.html" invoice.pdf
rm -rf "$tmpdir"

On Windows, use a unique temporary directory and pass its full path. Do not assume that changing the shell’s current directory alone repairs a stream: the stream still has no original filename to establish a base.

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

Fix 2: make asset references explicit

Use a reachable HTTPS or HTTP URL

For assets hosted by a server, replace a relative reference such as css/style.css with an absolute URL such as https://example.com/css/style.css. The converter must be able to reach that URL from the machine running wkhtmltopdf, and the server must return the intended content.

Rank #2
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
  • Edit PDFs with Ease. Modify text, images, and layouts directly within your PDF documents.
  • Convert & Organize. Export PDFs to Word, Excel, or ePub, and organize files with ease.
  • Read & Annotate. Enjoy intuitive reading modes and powerful tools to comment, highlight, and mark up PDFs.
  • Create & Manage PDFs. Create new PDFs, combine multiple files, scan documents, and compress for easy sharing.
  • Fill & Sign Forms. Complete forms and digitally sign documents with secure e-signature tools.

Use an absolute local file URL

For local assets, use a fully qualified file:/// URL with the correct path syntax for the target operating system. For example:

<link rel="stylesheet" href="file:///srv/site/css/style.css">

Verify the path independently and test with the exact installed binary. A path that exists in a web container, chroot, or build machine may not exist in the process that runs wkhtmltopdf.

Do not confuse link rewriting with a CSS base fix

The usage documentation lists --resolve-relative-links for external links. That option is not a general solution for finding local CSS, images, fonts, or scripts when the HTML arrived through stdin (wkhtmltopdf usage documentation).

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.

Fix 3: keep stdin, but control what the HTML can reach

Some pipelines must stream generated HTML. In that case, make every local resource explicit before writing the stream, or serve the resources from a URL reachable by the converter. A typical stream command is:

generate-report 
  | wkhtmltopdf - report.pdf

This is safe only if generate-report emits absolute, valid references. If it emits relative paths inherited from a template, change the template or materialize a named temporary file instead.

Rank #3
Adobe Acrobat Pro | PDF Software | Convert, Edit, E-Sign, Protect | PC/Mac Online Code | Activation Required
  • Create and edit PDFs. Collaborate with ease. E-sign documents and collect signatures. Get everything done in one app, wherever you go.
  • Edit text and images without jumping to another app.
  • E-sign documents or request e-signatures on any device. Recipients don’t need to log in to e-sign.
  • Convert PDFs to editable Microsoft Word, Excel, or PowerPoint documents.
  • Share PDFs for collaboration. Commenting features make it easy for reviewers to comment, mark up, and annotate.

Separate path resolution from local-file permission

wkhtmltopdf has switches governing local-file access. The usage documentation describes --allow <path> as permitting access to files under a specified path and documents local-access switches (usage documentation). The library setting load.blockLocalFileAccess controls whether local and piped files may access other local files (libwkhtmltox settings).

These settings answer “may the converter read this file?” They do not answer “what directory does css/style.css mean?” Solve both questions independently:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Symptom Likely class of problem What to check
Warning names an unexpected path such as /tmp/style.css Relative reference has the wrong base Use a named input file or an explicit URL/path
Warning says local access is blocked or denied Permission policy Review --allow and local-access switches; allow only required directories
HTTP asset returns an error Network, authentication, DNS, or server response Fetch the exact URL from the conversion host and inspect the response
Only fonts or images disappear Those resources still use relative or inaccessible references Make each reference explicit and test its path separately

For a controlled local tree, a command may look like:

wkhtmltopdf --enable-local-file-access 
  --allow /srv/site 
  /srv/site/page.html /srv/output/page.pdf

Use the narrowest allowed directory. Do not enable broad filesystem access merely to hide a path-resolution mistake.

Security when the HTML is not fully trusted

HTML-to-PDF conversion can expose local files if the process has excessive permissions. The project’s AppArmor guidance states: “Wkhtmltopdf is not recommended for use when rendering HTML you don’t explicitly trust, a Mandatory Access Control system is useful for limiting just how much of your local filesystem an attacker can potentially grab if you are using wkhtmltopdf on untrusted content.” Read the operating-system-specific guidance at the project’s AppArmor page.

Rank #4
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
  • Perfect Adobe Acrobat Pro alternative – lifetime license for Windows 10 and 11.
  • EDIT text, images, pages, hyperlinks, designs in PDF documents. ORGANIZE PDFs.
  • READ and Comment on PDFs – Intuitive reading modes & document commenting and mark up tools!
  • CREATE, COMBINE, SCAN and COMPRESS PDFs.
  • FILL forms & Digitally Sign PDFs. Work with Digital certificates
  • Run conversion under a dedicated, low-privilege account.
  • Allow only the asset directory required for the job.
  • Keep secrets, configuration files, and private keys outside that directory.
  • Apply an OS-level confinement policy where available.
  • Reject or sanitize untrusted HTML rather than relying on a command-line flag alone.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failures and precise fixes

The named file works, but the pipe fails

This matches the documented failure pattern. Keep the named-file invocation, or rewrite every relative resource to an explicit reachable reference before piping. Include the exact warning in your diagnostic record.

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

--enable-local-file-access did not help

That switch changes access policy, not the base directory used to interpret a relative URL. Confirm the resolved path first, then grant access only if the resolved, intended path is permitted.

The absolute path still fails

Check operating-system syntax, case sensitivity, container mounts, symbolic links, and the user running wkhtmltopdf. Test that user can read the file and that the conversion process sees the same filesystem.

Remote assets work in a browser but not in the PDF

Verify DNS, TLS, authentication headers, redirects, and firewall rules from the conversion host. A browser session may have cookies or network access that the converter does not.

You need to report a reproducible bug

Follow the project’s support instructions at wkhtmltopdf support. Include wkhtmltopdf --version, operating-system/version, working directory, both commands, the smallest HTML and asset tree, and the complete warnings. The repository is archived, so avoid assuming a current upstream fix or support timeline.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
PDF Pro 3 - PDF editor to create, edit, convert and merge PDFs - 100% Compatible with Adobe Acrobat - for Windows 11, 10, 8.1, 7
  • ALL-IN-ONE SOLUTION – read, edit, convert, merge and protect your PDF files
  • MAXIMUM FUNCIONALITY – create interactive forms, compare PDFs, bates numbering, find and replace text or colors, convert documents, OCR engine, comment, highlight, fill out and print forms, document protection and others
  • EASY TO INSTALL AND USE – well-structured user-interface, in-program instructions, free tech support whenever you need it
  • GREAT VALUE FOR MONEY - why spend a fortune if you can have maximum functionality at a reasonable price - this also fits the requirements of companies very well

Performance and reliability choices

Workflow Strength Risk or cost
Named local file Preserves file-relative context and is easy to reproduce Requires temporary-file lifecycle and cleanup
Stdin with explicit URLs Fits streaming pipelines and avoids an HTML temporary file Every asset must be rewritten and network access must be reliable
Absolute local paths Avoids ambiguity and can remain offline Paths differ across hosts, containers, and operating systems

For repeatable builds, pin the wkhtmltopdf binary supplied to production, log its version, preserve warnings, and test both a representative document and a minimal relative-path fixture after deployment. If assets are large or numerous, local access generally avoids network variance, but it increases the importance of strict filesystem permissions.

Or skip the browser setup

If your goal is a clean screenshot or PDF of a reachable webpage rather than debugging a local wkhtmltopdf asset tree, ScreenshotNeo provides a website screenshot API and MCP server. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status.

One GET request is enough; see the ScreenshotNeo documentation for all parameters:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. Its Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Start at the free ScreenshotNeo sign-up.

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

Frequently Asked Questions

Is stdin-relative-path failure guaranteed on every wkhtmltopdf build?

No. The documented report demonstrates the behavior in one environment. Reproduce it with your exact binary, operating system, HTML, assets, and commands before changing production code.

Does changing the shell working directory establish the stream’s base URL?

Not reliably. A stdin stream still has no source filename; use a named temporary HTML file or explicit asset URLs.

Should I enable local-file access for untrusted HTML?

No. Restrict access instead, run with least privilege, and use operating-system confinement such as an appropriately configured AppArmor policy.

Quick Recap

Bestseller No. 1
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.; CREATE, COMBINE, SCAN and COMPRESS PDFs
$99.99
Bestseller No. 2
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
Edit PDFs with Ease. Modify text, images, and layouts directly within your PDF documents.; Convert & Organize. Export PDFs to Word, Excel, or ePub, and organize files with ease.
$99.99
Bestseller No. 3
Adobe Acrobat Pro | PDF Software | Convert, Edit, E-Sign, Protect | PC/Mac Online Code | Activation Required
Adobe Acrobat Pro | PDF Software | Convert, Edit, E-Sign, Protect | PC/Mac Online Code | Activation Required
Edit text and images without jumping to another app.; Convert PDFs to editable Microsoft Word, Excel, or PowerPoint documents.
$239.88
Bestseller No. 4
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
Perfect Adobe Acrobat Pro alternative – lifetime license for Windows 10 and 11.; EDIT text, images, pages, hyperlinks, designs in PDF documents. ORGANIZE PDFs.
$99.99
Bestseller No. 5
PDF Pro 3 - PDF editor to create, edit, convert and merge PDFs - 100% Compatible with Adobe Acrobat - for Windows 11, 10, 8.1, 7
PDF Pro 3 - PDF editor to create, edit, convert and merge PDFs - 100% Compatible with Adobe Acrobat - for Windows 11, 10, 8.1, 7
ALL-IN-ONE SOLUTION – read, edit, convert, merge and protect your PDF files
$29.99

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.