Skip to content
Search questionsBy 8 min read

PDF title from Markdown: 10 questions, tested

Questions people type when a PDF made from Markdown or HTML has the wrong title, no author or the wrong file name. Each one has a short answer, and a run that was read back from the PDF on 27 November 2026. Two of them are searches this site appeared for in November: "edit markdown document title for pdf" and "markdown to pdf with headers and footers".

  • 5 one line
  • 4 with a workaround
  • 1 not in the api
  1. How do I edit the document title of a PDF made from Markdown?One line. Start with a heading; for other text, one line in scripts.
  2. Why does my PDF's title say about:blank?One line. It was fixed on 13 November: render the file again.
  3. Which title wins: title tag, heading, front matter or the scripts option?One line. Scripts first. Then HTML keeps its title tag; Markdown takes the heading.
  4. Do accents, emoji, ampersands and long titles survive?One line. Yes. A title taken from a heading stops at 200 characters.
  5. How do I set the author, subject and keywords of the PDF?With a workaround. Not in the API. Set it on the finished file.
  6. What shows in the browser tab when the PDF opens?With a workaround. It follows the Title field; not measured in a viewer.
  7. Can the PDF have bookmarks (an outline) from my headings?Not in the API. Not today. None of the PDFs had bookmarks.
  8. How do I name the PDF file after the document title?With a workaround. Name it yourself when you save. A short function does it.
  9. Can the title be printed at the top of every page?With a workaround. A CSS page margin box in the styles option works.
  10. What else is in the properties, and are two PDFs of one input identical?One line. Same Producer every time; two renders differ in their dates.

Question 1

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

One line

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.

Request
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 heading is printed on page 1; the line in the scripts field only changes the title. 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. Each successful render counts as one screenshot of your plan; the Free plan needs no card. See the plans.

Without a script the title follows the first heading, so you never type it twice. Use one line in the scripts option when the title should be text the page does not print. It runs after the page has loaded and before the PDF is printed.

scripts
document.title = 'Q3 report'

This exact line was run twice, on Markdown with a heading and on Markdown without one: the title read "Q3 report" both times. The renderer's source says an error inside a script does not fail the render (not tested here).

Question 2

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

One line

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.

Run of 12 November
# Quarterly report

Title field of the PDF

about:blank

Run of 27 November
# Quarterly report

Title field of the PDF

Quarterly report

HTML input changed the same way: with no title tag, or an empty one, the first heading is used, and Document when there is no heading.

A title tag in Markdown no longer works

In the run of 12 November a tag such as <title>Q3 report</title> inside Markdown named the PDF. In the run of 27 November 2026 it did not: the converter now writes its own title from the first heading, ahead of anything in your text. The article on the annotated Markdown request still recommends the tag. Use the scripts option instead.

Question 3

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

One line

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.

19 inputs, one at a time. Pick one and read the card of the PDF that came out.

Markdown input

HTML input

What goes in

# Quarterly report

Revenue grew.

What the PDF says about itself

Title
Quarterly reportSet
Author
empty
Subject, Keywords
empty
Creator
The browser's user-agent text (HeadlessChrome/153.0.0.0)
Producer
Skia/PDF m153
Title bar flag
DisplayDocTitle true
Bookmarks
none

The first heading became the title. Nothing else was needed.

Wins 1

The scripts option

It runs last, and its value replaced both a heading and an HTML title tag.

Wins 2

HTML: title tag. Markdown: heading

HTML keeps a title tag with text. Markdown ignores the tag and takes its first heading.

Wins 3

Document

What is left with no heading. In HTML, the first heading is tried before this word.

Question 4

Do accents, emoji, ampersands and long titles survive?

One line

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.

  • Accents, Japanese, emoji

    Café — Übersicht 日本語 📄 came back exactly as written.

  • Quotes, brackets, backslash

    All kept. They are escaped inside the file and decoded by the reader.

  • Formatting in a heading

    Bold and code marks were dropped. An ampersand stayed one character.

  • Spaces and line breaks

    Collapsed to single spaces and trimmed at the ends, like a browser tab.

  • Length

    A 300-character HTML title tag came back whole. A 300-character Markdown heading was cut to 200.

  • A second heading

    Not used. The first heading named the PDF, even when the second was bigger.

Keep it readable anyway. The W3C technique for PDF titles asks for a title that identifies the document, plus the flag that tells a viewer to show it.[3]

Question 5

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

With a workaround

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 service has no field for author, subject or keywords, and the meta tags that browsers and other converters read did nothing here. With all three tags in the HTML, and with a meta tag added by the scripts option, the fields stayed empty. So fix the finished file. The script below was run on 27 November 2026 against a PDF the renderer had made, with @cantoo/pdf-lib 2.11.1, a maintained fork of pdf-lib. The original package's latest release is from 6 November 2021.[4][5]

recipe.mjs
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 as node recipe.mjs in.pdf "Invoice 2026-0042: Ana Pop" "Ana Pop". Read back with pdf.js: Title "Invoice 2026-0042: Ana Pop", Author "Ana Pop", Producer "Skia/PDF m153", in the file invoice-2026-0042-ana-pop.pdf. The option updateMetadata: false keeps the original Producer and dates; without it the library wrote its own Producer and a new modification date. The same call also sets the flag for the window title bar.[2]

The Creator field holds the browser's user-agent text, Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/153.0.0.0 Safari/537.36. The user_agent option did not change it (a test with MyBot/1.0 left it as it was).

Question 6

What shows in the browser tab when the PDF opens?

With a workaround

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.

What was and was not measured

On 12 November I tried to read the tab title from the browser's own PDF viewer. In headless mode the page title came back empty for all 7 files, with or without a Title, so the tab itself is not measured. What is measured is the file: all 19 PDFs of the title cases carried the Title field and the flag DisplayDocTitle true, which is the flag that asks a viewer to show the title in its title bar.[3]

Open the file in the viewer you care about and look at the tab. If it shows Document or the wrong heading, the Title field is the cause, and question 1 fixes it. If it shows a file name instead, that viewer is not using the Title for its tab.

Question 7

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

Not in the API

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.

Headings do not become bookmarks. Chromium can write an outline, but only when it is asked for it and for tagged output at the same time. The service sends neither, so there is nothing to switch on. The table is the same page printed four ways with Playwright's own call in the renderer's browser; the API did not make these files.[1]

Print optionsBytesOutline read back
Neither option (what the API does)12,940No outline
outline only12,940No outline
tagged only14,954No outline
outline and tagged15,633One top entry "Quarterly report", with "Costs" (holding "Detail") and "Outlook" below it

Both options together added 2,693 bytes to a one-page file of 12,940. If you need bookmarks now, add them to the finished file with a PDF tool, or print with a browser you run yourself.

Question 8

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

With a workaround

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 file you download is named screenshot- and the first 12 characters of the id, then .pdf. That is read from the source of the response headers, not from a live response. With curl, --output picks the name, and in code you pick it when you write the bytes. The function in the recipe above makes a name from the title. Seven titles through it:

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

Anything outside a to z and 0 to 9 is dropped, so a title written only in Japanese becomes document.pdf. Keep the title in your own code and name the file from that, instead of reading it back out of the PDF.

Question 10

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

One line

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.

FieldIn the 19 PDFs of the title cases
ProducerSkia/PDF m153 in 19 of 19
PDF version1.4 in 19 of 19
CreatorThe browser's user-agent text, in every file
DatesCreation and modification both set to the render time
Author, outline, XMP packet0 of 19 had an Author, 0 an outline, 0 an XMP packet

Two renders of the same input, the second started 1.2 seconds after the first ended, were both 11,936 bytes. Their SHA-256 hashes started 9f29a6d11fcf and 52e2e977c967: the dates differ, so the files do. To tell whether a document changed, compare the Markdown or the extracted text, not the PDF.

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 19 cases of question 3, the four print variants of question 7 and the four header variants of question 9 are the runs behind the tables; the figures in the prose are counts of those files.

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 tab title and the file name the service sends were not measured; both say so above. The results are for this renderer, this browser version and short files. For the request fields themselves, see HTML and Markdown input and PDF rendering.

Questions people ask

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.

Screenshot any page in one step

Paste an address into CurlShot and download the screenshot. A free account gives you 50 screenshots every month. No card needed.