Pagebreak After Heading on PDF Export

Using version 1.0.192 on Windows 10.

Here is the problem:

I have this in my userstyle css, but it seems to be being ignored:

@media print {

    @page {
        margin: 72pt;
    }
    h1, h2, h3, h4, h5, h6 {
        break-after: avoid-page !important;
    }
}

Any ideas?

Did you really restart the app? Closing the main window is not enough.

Yes, I have the tray disabled on joplin as well. I synchronized, restarted PC, and generated PDF again and it still puts the line break directly after the heading in spite of the break-after css.

Hmm, in this case I’m not really sure what the problem is. My print settings are honored, but I ran into the same issue with the page break.
Unfortuntely I don’t know too much about css. I took an HTML test page added the break-after, opened it with a browser and printed to PDF. Same result. The heading is still at the bottom of the page.

Hi,
I'm also interested in this subject.
I've read this, but I don't know what is a “generated box”.

“ The **`break-after property sets how page, column, or region breaks should behave after a generated box. If there is no generated box, the property is ignored.

Source

With more informations about “generated boxes”, I’ve tried to add a “div” block to the print media rules, like this

<style>
@media print {
div {
    @page {
        margin: 72pt;
    }
    h1, h2, h3, h4, h5, h6 {
        break-after: avoid-page !important;
    }
}
}
</style>

Now, the page break works in the PDF file. Is this correct CSS?

![PageBreakJoplin](upload://3U9XaZQhto93fKXv3Mq0Ff1Wl6i.png) 

![PageBreakPDF](upload://uFLegj2h52ZQuGnorV0pleYpfdw.png)

I know very little about css, but this doesn’t seem valid to me. I tested it and it remove the margin, “fixing” the problem of the page break on my document but not actually fixing it.

This break-after method is how I generated PDFs with asciidoctor when I used to use that, and it works. Not sure why it isn’t working in Joplin.

It doesn't work in Firefox or Chrome either. This is what I'm trying to tell you, asciidoctor is a processor similar to LaTeX, thus making this wotk in such a program is rather easy.
Joplin just uses the Chromium rendering engine. So, if that engine ignores css, there's nothing we can do about it.
The documentation for page-break also states if possible, so maybe the engine doesn't deem it possible.