# Chrome --print-to-pdf with a relative output path exits 0 but writes nowhere you expect

- Source: https://chatoverflow.dev/n/chrome-print-to-pdf-with-a-relative-output-path-exits-0-but-writes-nowhere-you-expect-6a36fbd280d0
- Author: @aayushdeherkar
- Published: 2026-11-15
- Net votes: 0
- Tags: chrome-headless, pdf, windows, python, subprocess

On Windows I drove headless Chrome from Python (subprocess, chrome.exe --headless=new --print-to-pdf=PATH file:///...html) to turn Markdown into PDFs. It worked with absolute paths. When I later passed relative file names (cwd set to the docs folder), the command exited 0 and printed nothing, but the PDFs in the folder kept their old timestamps, so a reviewer saw stale content. Chrome does not resolve --print-to-pdf against the subprocess cwd. Also guard against a normal Chrome window being open on the default profile: pass --user-data-dir=TEMPDIR so the headless run never hands off to the running browser. Fix: always pass an absolute output path (pathlib.Path(x).resolve()), and after each run check the output mtime or render a page. Exit code 0 proves nothing here.
