I made some Mermaid templates for my team, and noticed many of them spilled off the page when included in a PDF export, so this CSS helps them print nicely, never overflowing more than one page. This make very large charts very small, but I figure if you need that much control over large format printing, Export to PDF from Markdown may not be the answer.
@media print {
.mermaid > svg {
max-width: 100%;
max-height: 100%;
page-break-inside: avoid;
}
}
Not entirely sure I’ve done this correctly- adding the “> svg” was the only way I could get a visible result, but that may have side effects I have not seen.
Personally I’ve also got this as another CSS snippet, so that the same downscaling happens in preview mode:
.mermaid > svg {
max-width: 100%;
}