mkdocs-exporter icon indicating copy to clipboard operation
mkdocs-exporter copied to clipboard

Use different color scheme to export PDFs

Open fengtality opened this issue 1 year ago • 1 comments

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"

fengtality avatar Dec 03 '23 16:12 fengtality

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 avatar Dec 04 '23 19:12 adrienbrignon

Closing for now, workarounds are available using CSS.

adrienbrignon avatar Jun 22 '24 08:06 adrienbrignon