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
- 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.
- Why does my PDF's title say about:blank?One line. It was fixed on 13 November: render the file again.
- 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.
- Do accents, emoji, ampersands and long titles survive?One line. Yes. A title taken from a heading stops at 200 characters.
- 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.
- What shows in the browser tab when the PDF opens?With a workaround. It follows the Title field; not measured in a viewer.
- Can the PDF have bookmarks (an outline) from my headings?Not in the API. Not today. None of the PDFs had bookmarks.
- 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.
- Can the title be printed at the top of every page?With a workaround. A CSS page margin box in the styles option works.
- 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.
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.pdfThe 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.
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.
# Quarterly report
Title field of the PDF
about:blank
# 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
<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 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
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 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 |
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:
| 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 |
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 9
Can the title be printed at the top of every page?
With a workaround
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.
"Markdown to pdf with headers and footers" is one of the November searches. The service has no header option, and its PDF options are paper size, orientation, backgrounds, margins and one long page. CSS can fill the gap. Chromium reads page margin boxes, so a rule in the styles option puts text in the top and bottom margins of every page.
@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 |
With the default margin of 0 the head appeared and no page number did. The file had 3 pages with no margin and 4 with 20 mm. The text in the CSS is fixed: it does not follow the Title, so build the string from the same variable in your code. Playwright's own header template can print the document title, but this service does not expose it.[1]
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.
| Field | In the 19 PDFs of the title cases |
|---|---|
| Producer | Skia/PDF m153 in 19 of 19 |
| PDF version | 1.4 in 19 of 19 |
| Creator | The browser's user-agent text, in every file |
| Dates | Creation and modification both set to the render time |
| Author, outline, XMP packet | 0 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.
Sources
- [1]Playwright documentation, Page.pdf: the outline and tagged options (added in v1.42, off by default) and the header template classes. Checked .
- [2]pdf-lib documentation, PDFDocument.setTitle and the showInWindowTitleBar option. Checked .
- [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. Checked .
- [4]npm registry, pdf-lib package: latest version 1.17.1, published 6 November 2021. Checked .
- [5]npm registry, @cantoo/pdf-lib package: version 2.11.1, published 15 September 2026, MIT licence. Checked .
Read next
- Annotated requestA Markdown to PDF request, read line by lineOne 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.
- Recipe cardInvoice PDF from HTML: a recipe cardAn 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.
- ReferenceWeb page to PDF: paper sizes, margins, print CSSPaper 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.