Thanks for the tip regarding @media print {}. That works well to specify css that only affects PDF output.
However, that doesn’t solve the problem I’m seeing.
The issue is that export to PDF seems to be ignoring the cssclass: directive in the frontmatter. I can get regular css to appear in the PDF, e.g. h1 { color:green; }, but if I add a page-level class to the frontmatter using cssclass: it does not appear in the PDF.
I’ve attached a mini-vault that demonstrates the issue. To see it, unzip the vault and load it in Obsidian, and see that “Regular Page” has black headers and “Special Page” has green headers using the cssclass directive. Then export “Special Page” to PDF and observe that the PDF headers are black, not green.
Just bumping this, because it’s not just about @media print {} (and I should know this since I’m one of the only few people working on @media print{} in Obsidian at the moment.
the HTML for PDF renders drops CSSclasses (the cssclass here being cornell)
Unfortunately the lack of the css class applied to the .markdown-preview-view.markdown-rendered section means that people cannot print or export to PDF except what is already originally rendered in the original theme, which kinda defeats the entire purpose of CSS classes. For use cases, stuff like LaTeX rendered document printing cannot be supported in-house by a theme that usually doesn’t look like LaTeX, or things like clean-embeds cssclasses won’t print as such.
if you see the second image from the previous post, .markdown-preview-view.markdown-rendered has .cornell appended to the back of it. This behaviour is not replicated in .print > .markdown-preview-view.markdown-rendered (first image)