I don't know how it could be added to joplin but usually, to be able to handle PDF and printing media with CSS, we do like that:
for example
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel="stylesheet" type="text/css" href="impression.css" media="print">
Thus, when "printing" a webpage or exporting to a PDF ; impression.css
will be used and not styles.css
May be a a new Customer CSS could be added like describe in the doc
~/.config/joplin-desktop/userstyle.css
and add
~/.config/joplin-desktop/print-userstyle.css
a try do make would be to add
@media print {
}
to ~/.config/joplin-desktop/userstyle.css
EDIT : I made that try
added to ~/.config/joplin-desktop/userstyle.css
@media print {
body {
width: auto!important;
margin: auto!important;
font-family: serif;
font-size: 12pt;
background-color: #fff!important;
color: #000!important;
}
p, h1, h2, h3, h4, h5, h6, blockquote, ul, ol {
color: #000!important;
margin: auto!important;
}
.print {
display: block; /* affichage des �l�ments de classe print */
}
p, blockquote {
orphans: 3; /* pas de ligne seule en bas */
widows: 3; /* pas de ligne seule en haut */
}
blockquote, ul, ol {
page-break-inside: avoid; /* pas de coupure dans ces �lements */
}
h1 {
page-break-before: always; /* chaque titre commence sur une nouvelle page */
}
h1, h2, h3, caption {
page-break-after: avoid; /* pas de saut apr�s ces �l�ments */
}
a {
color: #000!important;
text-decoration: underline!important;
}
a[href]:after {
content: " (" attr(href) ")"; /* affichage des URL des liens */
}
}
thus this will only impact "print" media and PDF file
All that tricks come from a famous website known for its knowlegde with CSS / HTML named alsacreations
the CSS come from here
here is a sample of a tips for ansible I stored in joplin