# PDF title from Markdown: 10 questions, tested

> Ten questions on the title, author, tab, bookmarks, file name and header of a PDF made from Markdown, each answered by a run read back with pdf.js.

Search questions by Serghei Pogor, founder of CurlShot (https://curlshot.com/about/serghei-pogor). Published 1 December 2026. Page for people: https://curlshot.com/blog/pdf-title-metadata-from-markdown

A PDF made from Markdown by CurlShot takes its title from the first heading. For different text, send document.title = 'Q3 report' in the scripts option: in a run on 27 November 2026 a title tag written in the Markdown was ignored. With no heading the title is Document. Meta tags set no author, and the API sends no outline option, so the PDFs had no bookmarks.

## Key facts

- A PDF made from Markdown takes the first heading as its title. With no heading it is called Document.
- A title tag written in Markdown was ignored, with or without a heading. One line in the scripts option sets any title. In HTML input a title tag still works.
- Author, Subject and Keywords stayed empty with all three meta tags present. A short script with a PDF library set them on the finished file.
- No PDF had bookmarks: Chromium needs both the outline and tagged options, and CurlShot sends neither. A CSS page margin box in the styles option did put a running head on 3 of 3 pages.
- Two renders of one input were the same size and not the same bytes, because the dates differ. Compare input or text, not PDF hashes.

## The ten questions

1. How do I edit the document title of a PDF made from Markdown? One line.
2. Why does my PDF's title say about:blank? One line.
3. Which title wins: title tag, heading, front matter or the scripts option? One line.
4. Do accents, emoji, ampersands and long titles survive? One line.
5. How do I set the author, subject and keywords of the PDF? With a workaround.
6. What shows in the browser tab when the PDF opens? With a workaround.
7. Can the PDF have bookmarks (an outline) from my headings? Not in the API.
8. How do I name the PDF file after the document title? With a workaround.
9. Can the title be printed at the top of every page? With a workaround.
10. What else is in the properties, and are two PDFs of one input identical? One line.

Score: One line: 5, With a workaround: 4, Not in the API: 1.

## The answers

### How do I edit the document title of a PDF made from Markdown?

The first heading becomes the title, so start the Markdown with # and the title you want. For a title that is not printed on the page, send document.title = 'Q3 report' in the scripts option. A <title> tag written in the Markdown was ignored.

The request, from the documentation (not sent in this run):

```bash
curl -X POST "https://curlshot.com/api/v1/screenshot?access_key=YOUR_ACCESS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"format":"pdf","markdown":"# Quarterly report\n\nRevenue grew.","scripts":"document.title = \"Q3 report\""}' \
  --output q3-report.pdf
```

The scripts line, for a title that the page does not print:

```js
document.title = 'Q3 report'
```

### Why does my PDF's title say about:blank?

A new render should not say it. Before a change made on 13 November 2026, a document with no title tag got about:blank, the address of the empty page it was loaded in. Now the first heading names it, and a file with no heading is called Document. None of the 19 title cases said about:blank. A PDF made earlier keeps its old title: render it again, or edit the finished file.

In the run of 12 November the same Markdown with only a heading gave the title about:blank, and a title tag in the Markdown named the file. In the run of 27 November 2026 the heading names the file and the tag is ignored. If you added a tag for this, use the scripts option instead.

### Which title wins: title tag, heading, front matter or the scripts option?

The scripts option wins. After that, HTML keeps a title tag that has text, then takes the first heading, then the word Document. Markdown ignored the title tag: it takes the first heading, or Document. Front matter is not read as settings. Pick any case below to see the title that came out.

Each row is one case of the run of 27 November 2026. Author, Subject and Keywords were empty in all of them. A 300-character Markdown heading, not in the table, was cut to 200.

| Case | Input | Title field |
| --- | --- | --- |
| Markdown: Only a heading | # Quarterly report ⏎ Revenue grew. | Quarterly report |
| Markdown: Two headings | ## First heading ⏎ # Bigger heading | First heading |
| Markdown: Front matter | --- ⏎ title: Front matter title ⏎ author: Ana Pop ⏎ --- ⏎ # Quarterly report | title: Front matter title author: Ana Pop |
| Markdown: Title tag on line 1 | <title>Q3 report</title> ⏎ # Quarterly report ⏎ Revenue grew. | Quarterly report |
| Markdown: Title tag after the heading | # Quarterly report ⏎ <title>Q3 report</title> ⏎ Revenue grew. | Quarterly report |
| Markdown: Two title tags | <title>First</title> ⏎ # Heading ⏎ <title>Second</title> | Heading |
| Markdown: Title tag, no heading | <title>Q3 report</title> ⏎ Just a paragraph. | Document |
| Markdown: Scripts: your own title | # Quarterly report ⏎ scripts: document.title = 'Q3 report' | Q3 report |
| Markdown: Scripts: copy the heading | # Quarterly report ⏎ Revenue grew. ⏎ scripts: document.title = document.querySelector('h1').textContent | Quarterly report |
| Markdown: The same script, no heading | Just a paragraph. ⏎ scripts: var h = document.querySelector('h1'); if (h) document.title = h.textContent | Document |
| HTML: Title and meta tags | <title>Invoice 2026-0042</title> ⏎ <meta name="author" content="Ana Pop"> ⏎ <meta name="description" content="March invoice"> ⏎ <meta name="keywords" content="invoice, march"> ⏎ <h1>Invoice (heading text)</h1> | Invoice 2026-0042 |
| HTML: No title tag | <h1>Invoice (heading text)</h1> ⏎ <p>Total 120 EUR</p> | Invoice (heading text) |
| HTML: An empty title tag | <title></title> ⏎ <h1>Heading</h1> | Heading |
| HTML: No title tag, no heading | <p>Total 120 EUR</p> | Document |
| HTML: Title tag, then scripts | <title>Original title</title> ⏎ <h1>Heading</h1> ⏎ scripts: document.title = 'Changed by scripts' | Changed by scripts |
| HTML: Accents, CJK, emoji | <title>Café — Übersicht 日本語 📄 "quoted" (a) \ b</title> | Café — Übersicht 日本語 📄 "quoted" (a) \ b |
| HTML: Spaces and line breaks | <title> ⏎    Spaced   out  ⏎   title   </title> | Spaced out title |
| HTML: A 300-character title | <title>Annual report Annual report … (300 characters)</title> | Annual report Annual report … (all 300 characters came back) |
| Markdown: Formatting in a heading | # Report for **Q3** and `beta` & more | Report for Q3 and beta & more |

### Do accents, emoji, ampersands and long titles survive?

Yes. In an HTML title tag, accents, Japanese, an emoji, quotes, a backslash and 300 characters came back as written. In a Markdown heading, bold and code marks were dropped, the ampersand stayed, and a 300-character heading was cut to 200.

### How do I set the author, subject and keywords of the PDF?

The service has no option for them, and meta tags are ignored: Author, Subject and Keywords read empty with all three meta tags present. Set them on the finished file with a PDF library. A short script did it in the test.

The script below was run on 27 November 2026 against a PDF the renderer made. It read back Title "Invoice 2026-0042: Ana Pop", Author "Ana Pop" and Producer "Skia/PDF m153", and wrote the file invoice-2026-0042-ana-pop.pdf. It uses @cantoo/pdf-lib 2.11.1, a maintained fork of pdf-lib, because the original package's last release was on 6 November 2021 [4][5].

```js
import { readFile, writeFile } from 'node:fs/promises'
import { PDFDocument } from '@cantoo/pdf-lib'

const [input, title, author] = process.argv.slice(2)
const slug = (t) =>
  (t.normalize('NFKD').replace(/[\u0300-\u036f]/g, '').toLowerCase()
    .replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 60) || 'document') + '.pdf'

const pdf = await PDFDocument.load(await readFile(input), { updateMetadata: false })
pdf.setTitle(title, { showInWindowTitleBar: true })
pdf.setAuthor(author)
await writeFile(slug(title), await pdf.save())
console.log(slug(title))
```

Run it as `node recipe.mjs in.pdf "Invoice 2026-0042: Ana Pop" "Ana Pop"`. Loading with updateMetadata: false keeps Producer and the dates; without it the library writes its own Producer and a new modification date. The Creator field holds the browser's user-agent text and the user_agent option did not change it.

### What shows in the browser tab when the PDF opens?

The Title field, when the viewer follows the file's own flag, and all 19 PDFs of the title cases carried that flag (DisplayDocTitle true). The tab itself was not measured: I could not open a viewer headless. Fix the Title and a viewer that follows the flag shows it.

The W3C technique for PDF titles asks for both the Title entry and the DisplayDocTitle flag [3]. The pdf-lib documentation says its showInWindowTitleBar option works for most PDF readers [2].

### Can the PDF have bookmarks (an outline) from my headings?

Not today. None of the PDFs had one. Chromium can write one, but only when two print options are on together, and the service sends neither. With both on, a test page got a three-level tree from its headings.

The same page, printed four ways in the renderer's browser with Playwright's own call (the API does not send these options):

| Print options | Bytes | Outline read back |
| --- | --- | --- |
| Neither option (what the API does) | 12,940 | No outline |
| outline only | 12,940 | No outline |
| tagged only | 14,954 | No outline |
| outline and tagged | 15,633 | One top entry "Quarterly report", with "Costs" (holding "Detail") and "Outlook" below it |

The outline and tagged options were added in Playwright 1.42 and are off by default [1].

### How do I name the PDF file after the document title?

The service names the download screenshot-<12 characters>.pdf, so name the file yourself when you save it. A short function turned seven titles into file names in the test.

The Content-Disposition header the service sets is inline; filename="screenshot-<first 12 characters of the id>.pdf" (read from the source, not from a live response). Seven titles through the function above:

| Title | File name |
| --- | --- |
| Invoice 2026-0042 | invoice-2026-0042.pdf |
| Q3 report | q3-report.pdf |
| Café — Übersicht 日本語 📄 | cafe-ubersicht.pdf |
| Terms & Conditions <draft> | terms-conditions-draft.pdf |
| Quarterly report | quarterly-report.pdf |
| (empty) | document.pdf |
| 80 letters "A" | 60 letters "a", then .pdf |

Characters outside a to z and 0 to 9 are dropped, so a title written only in Japanese gives document.pdf.

### Can the title be printed at the top of every page?

There is no header option, but a CSS page margin box in the styles option put a running head on every page, and page numbers too once the margin was 20 mm. The text is fixed in the CSS; it does not follow the title.

Put this in the styles option and set pdf_margin to 20mm:

```css
@page {
  @top-center { content: "Q3 report"; font-size: 9pt }
  @bottom-center { content: "Page " counter(page) " of " counter(pages); font-size: 9pt }
}
```

| Setup | Pages with the head | Pages with the number |
| --- | --- | --- |
| No styles, pdf_margin 20 mm | 0 of 4 | 0 of 4 |
| Margin boxes, margin 0 (the default) | 3 of 3 | 0 of 3 |
| Margin boxes, pdf_margin 20 mm | 4 of 4 | 4 of 4 |
| Margin boxes, @page margin 20 mm | 4 of 4 | 4 of 4 |

The file had 3 pages with no margin and 4 with 20 mm. Playwright's own header template can print the document title [1], but the service does not expose it.

### What else is in the properties, and are two PDFs of one input identical?

Every title case said Producer "Skia/PDF m153", PDF 1.4 and the browser's user-agent text as Creator. Two renders of the same input, the second started 1.2 seconds after the first ended, were both 11,936 bytes and not the same file: the dates differ.

Of the 19 PDFs of the title cases: 19 said Producer Skia/PDF m153, PDF 1.4 and DisplayDocTitle true; 0 had an Author, 0 an outline and 0 an XMP packet. Creator was always `Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/153.0.0.0 Safari/537.36`. Two renders of one input: 11,936 bytes each, SHA-256 starting 9f29a6d11fcf and 52e2e977c967. To detect a changed document, compare the input or the extracted text, not the PDF bytes.

## How it was tested

On 27 November 2026, with Chromium 153.0.8010.12, the full browser in new headless mode that the renderer launches, driven by Playwright 1.63.0, and the PDFs read back with pdf.js (pdfjs-dist 5.7.284, legacy build). Each case went through the renderer's own render() function, with the options parsed by the service's own option parser (format=pdf, everything else at its default: A4, margin 0, backgrounds on). The PDF it returned was read back with pdf.js: the Info dictionary (Title, Author, Subject, Keywords, Creator, Producer, dates), the XMP packet, the viewer preferences, the outline and the text of page 1. An earlier run on 12 November, before a change of 13 November to how documents are named, gave different titles; the figures here are from the later run. The run reports titles, counts and bytes, never milliseconds. The web tier was not part of the run (no access key on the lab host), so the request in this article was written from the documentation and the options code and was not sent. The results are for this renderer, this browser version and short files.

Start on the Free plan, which needs no card: see [pricing](https://curlshot.com/pricing). The PDF options are on [PDF rendering](https://curlshot.com/docs/pdf) and the input fields on [HTML and Markdown input](https://curlshot.com/docs/html-and-markdown).

## Questions

### How do I set the title of a PDF made from Markdown?

Start the Markdown with a heading: it becomes the title. For other text, send document.title = 'Q3 report' in the scripts option. In a run on 27 November 2026 a title tag written in the Markdown was ignored.

### Why does my PDF title say about:blank?

Files rendered before a change of 13 November 2026 could get it when they had no title tag. In the run of 27 November 2026 no file did: the first heading, or the word Document, was used. Render the file again.

### Can I set the author of the PDF?

CurlShot has no option for it, and meta author, description and keywords tags were ignored in the run. Set Author on the finished file with a PDF library such as @cantoo/pdf-lib.

### Does the PDF get bookmarks from my headings?

No. None of the test PDFs had an outline. Chromium writes one only when the outline and tagged print options are both on [1], and the service sends neither.

### Can the title appear in a header on every page?

There is no header option, but a CSS page margin box in the styles option printed fixed text at the top of 3 of 3 pages. Use a margin of 20 mm so the page numbers fit too.

## Sources

1. Playwright documentation, "Page.pdf: the outline and tagged options (added in v1.42, off by default) and the header template classes": https://playwright.dev/docs/api/class-page (checked 12 November 2026)
2. pdf-lib documentation, "PDFDocument.setTitle and the showInWindowTitleBar option": https://pdf-lib.js.org/docs/api/classes/pdfdocument (checked 12 November 2026)
3. W3C WAI, WCAG 2.1 Techniques, "PDF18: Specifying the document title using the Title entry in the document information dictionary of a PDF document": https://www.w3.org/WAI/WCAG21/Techniques/pdf/PDF18 (checked 12 November 2026)
4. npm registry, "pdf-lib package: latest version 1.17.1, published 6 November 2021": https://registry.npmjs.org/pdf-lib (checked 12 November 2026)
5. npm registry, "@cantoo/pdf-lib package: version 2.11.1, published 15 September 2026, MIT licence": https://registry.npmjs.org/@cantoo%2Fpdf-lib (checked 12 November 2026)

## Go deeper

- [Markdown to PDF](https://curlshot.com/tools/markdown-to-pdf)
- [HTML to PDF](https://curlshot.com/tools/html-to-pdf)
- [PDF rendering](https://curlshot.com/docs/pdf)
- [HTML and Markdown input](https://curlshot.com/docs/html-and-markdown)
- [Pricing](https://curlshot.com/pricing)

## Read next

- [A Markdown to PDF request, read line by line](https://curlshot.com/blog/markdown-to-pdf-request-annotated.md): One Markdown-to-PDF request, read line by line, with what each line does to the PDF: title, margins, code width, tables, links, footnotes, page breaks.
- [Invoice PDF from HTML: a recipe card](https://curlshot.com/blog/invoice-pdf-from-html.md): An invoice from HTML to an A4 PDF in one request: the HTML, the call, and a test of 41 invoices that shows which print CSS rules matter.
- [Web page to PDF: paper sizes, margins, print CSS](https://curlshot.com/blog/web-page-to-pdf-paper-sizes.md): Paper sizes in millimetres, inches, CSS pixels and points, how margins and page breaks work in a PDF of a web page, and the print CSS that controls them.
