adrienbrignon / mkdocs-exporter

📝 MkDocs Exporter is a powerful plugin for MkDocs that enables seamless conversion of single pages and/or the entire documentation into professional PDF files.
https://adrienbrignon.github.io/mkdocs-exporter/
MIT License
63 stars 0 forks source link

Use different color scheme to export PDFs #15

Closed fengtality closed 3 weeks ago

fengtality commented 7 months ago

Suggestion: add a flag that lets users select certain color scheme

For instance, my site defaults to the slate (dark theme) but ideally I'd like the PDF exporter to use the default (light) theme in generating documents

theme:
  palette:
    # - media: "(prefers-color-scheme: dark)"
    - scheme: slate
      accent: amber
      toggle:
        icon: material/brightness-2
        name: "Switch to light mode"
    # - media: "(prefers-color-scheme: light)"
    - scheme: default
      accent: deep purple
      toggle:
        icon: material/brightness-5
        name: "Switch to dark mode"
adrienbrignon commented 7 months ago

Hello @fengtality,

The light mode seems to be enforced when printing, based on the SCSS defined by MkDocs Material.

Now, concerning the accent colors not being respected, the issue seems to be coming from Paged.js after a quick look. I'll investigate further and provide a solution.

In the meantime, you may be able to override the CSS variables used by MkDocs Material during the rendering process (using the stylesheets property of the exporter-pdf plugin).

For instance, this documentation uses:

:root {
  --md-primary-fg-color: #EA2027;
  --md-accent-fg-color: #000000;
}
adrienbrignon commented 3 weeks ago

Closing for now, workarounds are available using CSS.