Any way to customize the format/styling of PDF export?

Hi all,

Is it possible to customize the styles, fonts, padding, etc. when you export a PDF from Joplin by going to File > Export All > PDF - PDF File ?

Here is an example export from one of my notes:

  1. The code block under "Synopsis" has no padding at all and looks bad.
  2. Overall, the fonts are too big - I'd like to reduce the font size across the board to fit more information.
  3. It would also be nice to change the page size.

It seems to retain some of my custom styles from userstyle.css, like the font.

Anyone know how this can be done?

Thanks for any help!

If you create an @media print section in your userstyle.css file any css stored within that section will only apply when the note is printed / exported to pdf.

@media print {
    @page {
        margin: 2cm 2cm 2cm 3cm;
        /* adds margins for the page - margin order top, right, bottom, left */
    }
    element {
        setting: value;
        /* example */
    }
}

As I only use a mono printer I use this to modify everything to render in black and white, but because it only applies to printing it does not affect anything on the screen. In fact I have divided my userstyle.css file into two sections; one for the screen and one for printing. This is just to keep the different requirements separate.

@media screen {
    body {
         font-size: 14px;
        /* example - on the screen the body text will be 14px*/
    }
}

@media print {
    body {
         font-size: 12px;
        /* example - when printed the same body text will be 12px*/
    }
}
1 Like

Thank you so much! This will work perfectly.

This is great, thanks for sharing. Any chance to add bookmarks as per the outline of the markdown? I can add toc, but that not appears as bookmarks as it does while exporting to pdf via Typora.
Thank you in advance

I am not a developer so I do not know if what you ask is possible. If one of the devs sees this then maybe they could comment if the component used to create PDFs can be set to create bookmarks from headings.

1 Like