Changing the font color in exported PDF's

Hey, I want to frequently export my Obsidian Notes to PDFs but a problem occured.
When I export the file to a pdf, it exports it in Light mode, eventhough I use the dark mode (current theme: Yin and Yan).
Therefore, I tried to change the background color and the font color manually to get the expected results. For the background color, I used a custom css snipped with the content:

@media print { .print .markdown-preview-view { -webkit-print-color-adjust: exact; background-color:#0A0D10; }

and it worked out fine. Now I am searching my way around the black font color, because a black font isn’t visibile on a black background.

Does anyone has an idea for a custom css snipped or a more elegant solution?

Thank you all in advance.

1 Like

I was looking for the same thing and found the same background color snippet then ran into the same issue with the font. Apparently Chromium is responsible for switching the background color, so I imagine it also is changing the font color. In that sense, it seems hopeful that once we get this snippet it will work.

That being said, I was kind of hoping to use this issue as a good excuse to force myself to figure out how to better use the developer interface to detect which css changes what.

I had checked the GitHub repo that has everything that @Klaas has kindly compiled, but haven’t quite found the snippet/s that solve this issue. I imagine it’s pretty easy, so am very curious to hear the responses! Thanks for posting this!

1 Like

Hello! This might be a bit late since you asked over a month ago but this is the code I use to change the font color in my exported PDFs:

@media print { 
    .print .markdown-preview-view { 
        -webkit-print-color-adjust: exact; 
        background-color: #202020; 
        color: #dcddde;
    }
}

This is what the end product looks like, I used the exact same colors as the basic dark theme of Obsidian.


Hope this helps!

1 Like