How to style the PDF with @media print?

Currently the PDF exported sports nothing as a style.
I suggest that the theme should come attached with a print.css file for CSS styling for PDFs, so pages are styled with theme specific design.
And the export thing will take print.css for styling the doc.

That’s for the design, how to get header and footer for the exported PDF? Any idea…

7 Likes

I’m moving this to #help and updating the title as I couldn’t find posts about this in the forum. You can style the PDF with @media print {}, there are a few suggestions in Discord for this.

2 Likes

https://css-tricks.com/snippets/css/print-url-after-links/ has a couple of tips, including this lovely suggestion that prints out the URL after every hyperlink.

@media print {
  a::after{
    content: " (" attr(href) ") ";
  }
}
4 Likes

How to add Header Footer or Border to PDF during export?

2 Likes
2 Likes

I have a css snippet. When I add

---
cssclass: p_indent
---

it, correctly, indents each paragraph in the markdown preview.
I also added this code so that when I export to pdf, it also indents the paragraphs. Unfortunately, it indents paragraphs regardless of whether the file has the cssclass p_indent.
image

How can I edit the above code so that only exported files with the p_indent cssclass get indented paragraphs?

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.