Markdown to PDF command line Linux pandoc including title metadata
- converting markdown to PDF, portable data format
- pandoc markdown pdf give document title
Why is getting the meta/page title set without having Pandoc take over writing the visible title so hard?
The manual seems to state quite clearly that “if you just want to set PDF or HTML metadata, without including a title block in the document itself, you can set the title-meta, author-meta, and date-meta variables.” https://pandoc.org/MANUAL.html#metadata-variables
But it does not work, at least not when run by this command: pandoc --pdf-engine=wkhtmltopdf --pdf-engine-opt=--enable-local-file-access -s -c tmp.css -o erpw-feedback-and-improvement.pdf erpw-feedback-and-improvement.md
Resulting in the message:
[WARNING] This document format requires a nonempty <title> element.
Defaulting to 'erpw-feedback-and-improvement' as the title.
To specify a title, use 'title' in metadata or --metadata title="...".`
Setting pagetitle
in the ---
yaml metadata gets rid of that message… but does not set the title to what is given!
The addition of title-meta
is not mentioned directly in the release changelog, but the one reference to it—documenting it in MANUAL—implies it has been around since before that change, in 2.7.3 (2019-06-11).
Add note about title-meta, author-meta, date-meta (#5486).
This is possibly (probably?) what is needed to make it work, but i do not understand it and i sort of refuse to accept that it should be this complicated:
Pandoc - Convert from Markdown to PDF and Set File Name From Metadata Title - Stack Overflow
Oh, and the --shift-heading-level-by=-1
option seems to be the recommended approach, but that would mean if you want a level 1 header at the start of your document followed by level 2 section headers, you would need to write your document with a level 1 header that you know will get thrown away, a level 2 header that you know will get promoted to level 1, and then level 3 sections that you know will get promoted to level 2.
And that is silly.
All i want is something that sets the PDF document metadata title and leaves the printed output alone.