How to create a new page for PDF export

Hello,
does anybody know how to create a "new page" if I want to export a note to PDF?
I have tried \newpage and \pagebreak but it didn't work.
Thank you very much in advance.
Kind regards

I am not sure what you are trying to achieve but if you are trying to add section page breaks you can associate a pagebreak with a particular HTML element.

If you put the below in userstyle.css

@media print {
    h2 {
        page-break-before: always;
    }
}

When you print or export a note to PDF it will add a pagebreak before every H2 header (created using ## in the Markdown editor)

You can see more details about page-break-before here and page-break-after here.

3 Likes

Thank you for your answer!
This is just for some notes I have to send to others in PDF format.
Without the page break it looks very chaotic.
I know that Joplin is not Word, but at least the page breaks would be fine.
I managed to get it to work with the userstyle.css, altough it is not optimal that I have to create a heading just for a page break.
It would be nice if there would be a button for the page break to get it to work without the custom css as I have seen, that \newpage and \pagebreak are markdown functions.

1 Like

This is something I am looking for as well; a manual way to insert a page break.

Markdown does not support page breaks so it's a feature you would need to add yourself using the technique mentioned by @dpoulton.

I guess you could also make it break on horizontal dividers:

@media print {
    hr {
        page-break-before: always;
    }
}

Then whenever you add * * * in the document you'll get a page break.

Another way would be to create a plugin which would insert some HTML tag like <span class="page-break"> whenever you press a button.

1 Like

That's a great option; I'm using it immediately! Thanks.

You could add this to your markdown at your desired breakpoint:

<div style="page-break-after: always; visibility: hidden"> 
\pagebreak 
</div>
5 Likes

Excellent suggestion, thank you! I'm using it as a snippet/template.