I needed every PDF I export from Joplin to carry my company's header and tagline. So far I'd been hard-coding them in the custom stylesheet, which had two problems. The text only appeared once (at the top of the first page and at the end of the note), and changing it meant editing CSS. This plugin replaces that with a settings page.
What is it?
A plugin that adds a header and footer to every page of a note when you export it to PDF. You type the text in Joplin's settings, with no CSS editing, and you can add page numbers and the date.
Repository: GitHub - tnoahc/joplin-pdf-header-footer Β· GitHub
Why this exists
Many of us have to produce documents that follow a house style: a company name at the top, a tagline or confidentiality line at the bottom, and page numbers. Joplin's PDF export doesn't offer that. Pasting CSS into userstyle.css gets you part of the way, but ::before/::after rules only print once per document, not once per page. And the text is buried in a stylesheet.
Current state
Version 1.0.0, released as a small .jpl with no dependencies. It's plain JavaScript, so there's no build step. I've tested it on Joplin desktop 3.7.21 (Linux) in development mode, exporting multi-page notes to PDF.
What works:
| Feature | Status |
|---|---|
| Header on every page: left, centre and right text | |
| Footer on every page: left, centre and right text | |
Placeholders: {page}, {pages}, {date} |
|
| Optional separator lines under the header and above the footer | |
| Adjustable font size and top and bottom page margins | |
| Note viewer unaffected (only exported PDFs change) | |
| File β Print |
For example, Page {page} of {pages} in the footer prints "Page 2 of 5".
How it works
My first idea was to use Electron's built-in header and footer options for printToPDF (displayHeaderFooter, headerTemplate, footerTemplate). Reading InteropServiceHelper.ts showed that this route is closed. Joplin builds the print options itself, and a plugin can't add to them.
Two other details in the same code made a plugin possible:
- To make a PDF, Joplin first exports the note to HTML with plugin content scripts applied, then prints that HTML in a hidden window.
- It prints with
preferCSSPageSize: true, so the document's own CSS@pagerules are respected.
So the plugin is a Markdown-it content script. It adds a <style> block with @page margin boxes (@top-left, @bottom-right and so on) to the rendered note. Chromium has supported these since version 131, and they repeat on every printed page. counter(page) and counter(pages) provide the page numbers. The content script reads your settings through pluginOptions.settingValue(), which also works during export. Because @page rules only apply in print, the viewer looks the same.
Setup
- Download
plugin.tnoahc.pdf-header-footer.jplfrom the latest release. - Go to Tools β Options β Plugins β
β Install from file, choose the file, and restart Joplin. - Fill in the text under Tools β Options β PDF Header & Footer.
- Export as usual with File β Export β PDF.
If your custom stylesheet already adds a header or footer through .exported-note::before/::after, remove those rules so the text doesn't appear twice.
Requires Joplin desktop 3.2 or later.
What's next
Ideas I'm considering. Tell me which would be most useful:
- A different header (or none) on the first page
- A logo image in the header
- Different header and footer text per notebook
- The note title as a placeholder
- Submission to the official plugin repository
Caveats
- File β Print doesn't include the header and footer. Joplin's print command doesn't load plugins, unlike the PDF export. Export to PDF first, then print the PDF.
- The note title isn't available as a placeholder yet. Joplin already prints it at the top of the note.
- Joplin's own PDF margin settings may interact with the plugin's margin settings. Adjust the top and bottom margins if the header sits too close to the edge.
- This was developed with AI assistance (Claude).
Feedback, bug reports and contributions are welcome. I'm particularly interested in how it behaves with other page sizes, other operating systems and custom stylesheets.
