Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober 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 Scan×
Skip to content
Chrome DevTools Protocol

Can Headless Chrome Generate PDFs with Bookmarks?

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

Yes. Headless Chrome can embed a navigable PDF document outline—the feature many readers call bookmarks—when you print through the Chrome DevTools Protocol and set Page.printToPDF‘s generateDocumentOutline option to true. That option is marked experimental, so check it against the Chrome version you deploy and inspect the resulting PDF in the viewer your users will use. The plain --headless --print-to-pdf command creates a PDF, but the documented command-line option alone does not establish that an outline is requested.

What “bookmarks” means in a PDF

In this question, bookmarks means a PDF document outline: a navigable list of sections shown in a PDF reader, typically in a side panel. It is distinct from ordinary clickable links in the page or PDF. Chrome’s DevTools Protocol describes generateDocumentOutline as controlling whether to embed that outline in the PDF. The current Page domain documentation marks the parameter experimental.

That distinction matters when choosing a capture route. A PDF can contain live links and still lack an outline. Conversely, requesting an outline is not a substitute for adding useful links to the document.

Choose the route that exposes the option

Route What it establishes When to use it
Headless command line: --print-to-pdf Saves the target page as a PDF. The documented command-line reference does not say this flag requests a document outline. Simple PDF capture when you do not require explicit outline control.
DevTools Protocol: Page.printToPDF with generateDocumentOutline: true Explicitly requests an embedded outline; the parameter is experimental. Automated generation where outline inclusion matters and you can validate the Chrome version and resulting files.

Chrome’s headless command-line reference also documents --no-pdf-header-footer to omit the print header and footer. It documents --timeout as a maximum wait before capture for commands including --print-to-pdf; it does not guarantee that asynchronous page content has finished rendering when that wait expires. For outline control, use the protocol option rather than assuming an undocumented CLI switch exists.

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

Generate an outlined PDF through CDP

The essential protocol parameter is small:

{
  "generateDocumentOutline": true
}

Send it as part of the Page.printToPDF request after navigating to the page and waiting for the content intended for print to be ready. The Chromium change that introduced the option, dated November 17, 2023, describes it as a request to generate an outline from content headers. That is useful implementation context, not a guarantee that every Chrome build or every heading arrangement will produce identical nesting. See the Chromium change record.

Example using Node.js and Puppeteer’s CDP session

This example uses Puppeteer to launch headless Chrome, load a page, send the protocol request, and write the returned PDF bytes. Install Puppeteer in your project first. The option itself belongs to CDP; confirm that the Chrome executable and protocol schema used by your installation accept it.

const puppeteer = require('puppeteer');
const fs = require('node:fs/promises');

(async () => {
  const url = process.argv[2] || 'https://example.com';
  const browser = await puppeteer.launch({ headless: true });

  try {
    const page = await browser.newPage();
    await page.goto(url, { waitUntil: 'networkidle0', timeout: 60000 });

    const cdp = await page.createCDPSession();
    const result = await cdp.send('Page.printToPDF', {
      generateDocumentOutline: true,
      printBackground: true
    });

    await fs.writeFile('page.pdf', Buffer.from(result.data, 'base64'));
    await cdp.detach();
  } finally {
    await browser.close();
  }
})().catch(error => {
  console.error(error);
  process.exitCode = 1;
});

Run it with node make-pdf.js https://your-site.example/article. The output is page.pdf in the current directory. generateDocumentOutline is the setting relevant to bookmarks; printBackground is included for page appearance, not outline generation. The example’s networkidle0 wait is a practical navigation choice, not proof that every application-specific render task has completed. Pages that populate content after network activity settles need an application-specific readiness signal before printing.

Structure the source page for a useful outline

Use real HTML headings for document sections: a main <h1>, section headings such as <h2>, and lower-level headings where they reflect actual structure. Do not use bold paragraphs or oversized styled <div> elements as substitutes if those passages are meant to be section headings. Chromium’s implementation record says the outline is generated from content headers, so semantic headings are the relevant input to test.

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

The available protocol reference and change record do not specify every selection rule, nesting rule, or behavior for malformed heading hierarchies. Avoid depending on a particular interpretation of skipped levels or unusual heading patterns without testing your content in the Chrome version you ship.

Check the actual PDF, not just the API response

  1. Open the generated file in the intended PDF reader and reveal its outline or bookmarks panel.
  2. Check that expected sections appear, the labels are understandable, and the nesting is usable.
  3. Try selecting entries to confirm navigation lands at the appropriate page or section.
  4. Repeat after changing the Chrome version, page template, or heading structure that contributes to the outline.

This output check is important because the protocol option is experimental, and Chromium’s implementation note is not a version-independent promise about how every PDF viewer displays the outline.

Make the page ready before printing

PDF generation captures a rendered page, not an abstract document model. A print request made too early can produce a file that technically exists but omits late-arriving text or images. The command-line documentation explicitly describes its timeout as a maximum wait before capture, even if a page is still loading. That means a longer timeout is not by itself a reliable content-readiness strategy.

  • Wait for the page navigation you require, then wait for application-specific content such as a report container or final heading to appear.
  • For pages that load data after initial rendering, use a readiness condition tied to that content rather than relying only on a generic wait.
  • Make sure headings are present in the rendered document before calling Page.printToPDF; otherwise the outline cannot reflect missing content.
  • When output is intermittent, compare a failed PDF with a successful one and check whether the page was still loading at capture time.

The Chrome headless reference documents timeout behavior and PDF creation; it does not establish a universal wait value for all sites or applications. Set the wait strategy to fit the page you control.

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

Options, wrapper support, and version checks

The protocol documentation labels generateDocumentOutline experimental. Experimental means you should validate its availability and behavior in the exact deployed Chrome build rather than assuming a wrapper or older browser exposes it unchanged. Puppeteer, Selenium, or another automation client may provide an interface to CDP, but the sources do not establish that every wrapper has a dedicated high-level bookmark switch. If a wrapper does not expose one, check whether it allows a raw CDP request and whether the protocol schema for its Chrome build includes the option.

Keep the protocol request and browser version together in deployment notes. When upgrading Chrome, generate a fixture PDF with representative headings and inspect it. This is especially useful for document pipelines that rely on a stable table of contents or section navigation. Do not silently treat a successful PDF response as proof that an outline was embedded.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting missing or unusable bookmarks

The PDF opens but there is no outline panel content

  • Confirm the request was Page.printToPDF and included generateDocumentOutline: true; a plain CLI print does not establish that the outline option was requested.
  • Check that the installed Chrome protocol schema supports the experimental option.
  • Confirm the page has semantic content headings by the time printing begins.
  • Inspect with the target PDF reader; do not infer outline presence solely from a non-empty PDF file.

The outline is empty or omits sections

Check whether the omitted section titles are real heading elements in the rendered page rather than visual styling on generic elements, and whether their content was loaded before printing. Because the documented sources do not provide a complete heading-selection algorithm, use a small representative page to validate the behavior you need rather than assuming every visual section becomes an entry.

The protocol call rejects the parameter

Check which Chrome binary Puppeteer or your automation client actually launched, then compare its protocol support with the DevTools Protocol documentation for the deployed version. The parameter is experimental, so a wrapper’s general ability to print PDFs does not prove that it accepts this particular field. Update or change the browser/client combination only after testing the output in your deployment environment.

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

The PDF is missing late content

Do not treat the CLI --timeout as proof of readiness: the reference defines it as a maximum wait, even if loading continues. Wait for the page’s actual content condition before issuing the print request. If the content remains absent, diagnose the page load independently of the outline setting.

Or skip the browser setup

If you need a screenshot or PDF capture API rather than a Chrome-based pipeline you manage, ScreenshotNeo is a separate option. It can return a PDF, but the information available here does not establish that its PDF output can request an embedded document outline or bookmarks; use the CDP route above when that specific control is required.

One-call screenshot example (replace the target 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. Cookie and consent banners, newsletter popups, and chat widgets are removed before the shot; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. ScreenshotNeo also has an MCP server for AI agents, with screenshot, page-info, and PDF-capture tools. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

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

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Frequently Asked Questions

Does an outline guarantee a specific nested bookmark hierarchy?

No universal nesting rule is established by the cited protocol reference or Chromium change record. Test the heading structure and generated PDF with the Chrome version and viewer you plan to use.

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.