PDF Workflows · 2026-12-06 · 11 min read
Permanent PDF Dark Mode: Make the File Itself Dark
A reader can make a white PDF look dark on one screen. The file is still white. Here is how to write dark mode into the PDF itself, with commands and a browser route.

Making PDF dark mode permanent is a different job from switching a reader to night mode. I work on RedesignPDF, and this distinction comes up again and again. A reader can make a white page look dark on one screen. The file is still white. Send it to an iPad, open it in Kindle, or send it to a print queue, and the white page comes back.
That is fine on your own laptop. It is not fine for a tablet, a shared review copy, or a Kindle library. This article covers what the reader changes, what a permanent dark PDF can preserve, and two routes I would use: a free command-line pipeline and the browser tool at PDF Dark Mode.
The file is a page, not a theme
A PDF page is a set of drawing instructions. A simplified text page often contains something like this:
1 1 1 rg
0 0 600 800 re f
0 0 0 rg
BT
/F1 11 Tf
72 720 Td
(Chapter 4: Results) Tj
ET
The first two lines paint a white rectangle over the page. The next line switches the pen to black. The text object then draws a heading at a fixed position. There is no theme: dark flag anywhere in that sequence. There is no CSS media query waiting for the operating system to announce sunset. The page says white paper and black ink, so that is what a renderer draws.
A reader that offers dark mode applies a color transform after it parses those instructions. Some readers invert the rendered canvas. Some dim it. Some keep images in color and invert only the text layer. Apple Books, Adobe Reader, Chrome extensions, and Kindle each make their own choice. None of those choices travel inside the file, and PDF 1.7 and 2.0 have no standard "this page is for dark reading" flag.
That is why the same PDF can look comfortable on your laptop and blinding on a tablet. The tablet is not ignoring your preference out of spite. It has a different renderer, and the PDF did not carry the preference with it. A print driver has the same problem. It receives white paper and black ink, and it prints white paper and black ink.
| What changed | Still dark after sending | Still dark on Kindle | Survives printing | Text stays selectable |
|---|---|---|---|---|
| Reader night mode | No | Usually no | No | Yes |
| Browser extension filter | No | No | No | Yes |
| Dark colors written into the PDF | Yes | Yes, if the viewer does not override | Yes, but it prints dark toner | Depends on method |
| Raster page with dark pixels | Yes | Yes | Yes, with the same toner cost | No, unless OCR adds a layer |
The last two rows are the ones that matter for a permanent result. The rest are display settings, and a display setting cannot put color into the file.
Four ways to make the change stick
| Method | What it changes | Keeps text layer | Keeps photo color | Best for |
|---|---|---|---|---|
| Global invert | Every pixel | No, after rasterizing | No, photos become negatives | Pure text pages with no images |
| Selective invert | Neutral pixels only | No, after rasterizing | Mostly, saturated pixels stay | Mixed pages with charts and photos |
| Vector recolor | Text and graphics operators | Yes | Yes, if images are handled separately | Files you can parse and test |
| Browser export | Page pixels, with color protection | Visual PDF, optional OCR | Yes, with color protection on | People who want a result without a toolchain |
A global invert is the one-liner everyone tries. It turns white paper black and black text white, then turns a red stamp cyan and a family photo into a negative. A selective invert is better. It flips neutral pixels and leaves saturated pixels alone, so stamps and charts keep their hue. A vector recolor is the highest-quality option because it changes text and graphics operators without rasterizing, but it needs careful parsing. The browser route gives you a visual result with color protection, without a local toolchain.
The free command-line route
This route uses Ghostscript to rasterize the pages, ImageMagick to remap the pixels, and img2pdf to rebuild the PDF. It is free, scriptable, and easy to inspect. It also throws away the original text layer, so read the limits before you use it on a contract or a file you need to search.
Install the tools first. You need Ghostscript, ImageMagick, img2pdf, Poppler for pdfinfo, and OCRmyPDF for the optional search step. On macOS with Homebrew:
brew install ghostscript imagemagick img2pdf poppler ocrmypdf
On Debian or Ubuntu:
sudo apt install ghostscript imagemagick img2pdf poppler-utils ocrmypdf
Debian and Ubuntu usually install ImageMagick 6 from apt, where the binary is convert (and composite for compositing) rather than magick. This article writes magick because that is the ImageMagick 7 name you get from Homebrew. If magick is not found, you are on IM6: run convert wherever you see magick, and the -fx, -level, -colorspace, and -quality flags below behave the same.
On Windows, use WSL and follow the Debian command. Native Windows builds exist, but the shell syntax below assumes a Unix-like environment.
Step 1: rasterize at a sensible resolution
mkdir -p dark-pages
gs -dSAFER -dBATCH -dNOPAUSE \
-sDEVICE=png16m \
-r200 \
-dTextAlphaBits=4 \
-dGraphicsAlphaBits=4 \
-sOutputFile=dark-pages/page-%03d.png \
input.pdf
Use 200 DPI for screen reading and 300 DPI for 8-point text or footnotes. Higher resolution gives ImageMagick more pixels and you a larger PDF. Check free disk space before a long file. The alpha bits settings smooth text and line art, but they cannot restore detail the scan never had.
Step 2: invert neutral pixels, not the whole page
This is the selective version. It checks the spread between the red, green, and blue channels. A near-neutral pixel has a small spread. A saturated red stamp or blue chart has a large one.
# ImageMagick 6 (Debian/Ubuntu) has no `magick` wrapper: use `convert` here.
for f in dark-pages/page-*.png
do
out="dark-pages/dark-$(basename "$f")"
magick "$f" \
-fx 'max(max(u.r,u.g),u.b)-min(min(u.r,u.g),u.b) < 0.08 ? 1-u : u' \
-colorspace sRGB \
"$out"
done
The 0.08 cutoff is a starting point. Raise it to 0.12 for warm paper, lower it to 0.05 if colored highlights invert. Test a face, a chart, and a stamp before the whole file. The -fx operator runs per pixel, so a 300 DPI chart can take a while. Start with one page.

If the document is pure black text on white paper and you do not care about images, this shorter command is enough:
magick dark-pages/page-001.png \
-colorspace Gray \
-negate \
-level 0%,88% \
dark-pages/dark-001.png
Do not use that shortcut on a page with a color logo. It will invert the logo along with the text.
Step 3: rebuild the PDF
img2pdf --output input-dark.pdf dark-pages/dark-*.png
Then check the page size and the page count:
pdfinfo input.pdf | grep -E 'Pages|Page size'
pdfinfo input-dark.pdf | grep -E 'Pages|Page size'

If the pages come out the wrong size, force A4 for a uniform document:
img2pdf --pagesize A4 --output input-dark.pdf dark-pages/dark-*.png
Do not force it on mixed sizes. PNG is lossless and large, so for a smaller file convert to quality-90 JPEG first:
magick dark-pages/dark-*.png -quality 90 dark-pages/dark-%03d.jpg
img2pdf --output input-dark.pdf dark-pages/dark-*.jpg
JPEG puts faint halos around small text. Compare 8-point type before you commit.
Step 4: add search only if you need it
A rasterized PDF has no text layer. OCR can add one, but most engines expect dark text on light paper:
ocrmypdf --force-ocr --output-type pdf input-dark.pdf input-dark-searchable.pdf
Search for a known phrase to test it. If search fails, keep a light searchable copy next to the dark one. Rasterizing a signed PDF also invalidates the signature, because the signature covers the original bytes.
The browser route without a terminal
The command line is repeatable. It is not for everyone. We built PDF Dark Mode for the browser: no install, and a result you can check on the device where you read.
The local Dark PDF and Recolor tabs process pages in the browser at 0 credits. Color protection is on by default, so photos, charts, and stamps are less likely to invert. You can pick charcoal or slate instead of pure black. Sign-in is required to export.
Open the page, drop in the PDF, and choose Dark PDF or Recolor. Apply it to the pages you want, then inspect a chart, a photo, and a red stamp. Export and open the file on the tablet with the network off. If it is still dark, the color is in the file.
The optional AI dark redesign costs 2 credits per page. Visitors get 2 free AI pages before sign-in, then 3 more after a free sign-in, which is 4 plus 6 credits and 5 AI pages. That is a designed dark layout, not a simple inversion. Check numbers, signatures, and small print.
The export is a visual PDF, with optional OCR. It is not Word, InDesign, or an AcroForm. If you need editable text, keep the original. If you need a dark reading copy, this is the shorter path.
A verification routine that catches the usual failures
Do not trust the preview on the machine where you made the file. Check it the way you will use it.
First, verify the exported PDF outside the app where you created it. Open it on a second device with the network off, or render it offline with pdftoppm and inspect a 16-level grayscale preview to see how the tones will hold up on an e-ink screen. If the rendered page is still dark with no viewer override, the color is in the file. If it is white, you exported a viewer setting or the wrong file.

Second, search for a phrase you know is on page one. If search returns nothing, the text layer is gone. That may be fine for a reading copy. It is not fine for a reference file you need to cite.
Third, inspect a colored chart, a photo, and a stamp at 100 percent zoom. A global invert will show up immediately. A selective invert may still shift skin tones or pale highlight colors. If the chart legend is now unreadable, the threshold is wrong.
Fourth, check the smallest text on the page. A 200 DPI render can make 7-point footnotes mushy. Rerun at 300 DPI if the source has the detail.
Fifth, check the file size and the print path. A dark PDF is for screens. Printing it uses far more toner than printing the original white page, and the result is often worse. Keep the light original for print and send the dark copy to the tablet.
When not to use a permanent dark PDF
A permanent dark PDF is a reading copy. It is not a good fit for a contract that needs a valid signature, a PDF/A archive, a file that must remain searchable, or a document you plan to print on paper. It is also a poor fit for a page where color carries meaning, such as a medical chart, a heat map, or a brand guideline, unless you have checked every color against the original.
For faded scans, fix the scan before you darken it. A dark mode filter on a low-contrast page makes a dim page darker. Use a contrast or cleanup step first, then decide whether you need dark mode at all. The darken scanned PDF page covers that separate job.
The honest summary is simple. A reader can fake dark mode on one screen. A permanent dark PDF puts the colors in the file, and then you have to decide what to do about text, photos, and print. The command line gives you control and takes away the text layer. The browser route gives you a faster result and asks you to review the colors. Neither one is magic. Both are better than sending a white page to someone who asked for a dark copy.
FAQ
Does PDF dark mode permanently stay on iPad and Kindle?
Yes, if the dark colors are written into the PDF. A viewer can still apply its own filter on top, but the file no longer depends on it. Test the export on the target device with the network off. If it stays dark, the color is in the file.
Can I keep the text selectable and still get a dark page?
Yes, with a vector-aware recolor that changes text and graphics colors without rasterizing. That is more work than the Ghostscript pipeline. A raster dark PDF loses the text layer unless OCR adds one, and OCR on white-on-dark text is unreliable. Test search before you rely on it.
Why did my photos turn into negatives?
You ran a global invert over every pixel. Use a selective invert that checks color saturation, or use a browser tool with color protection. A selective invert is not perfect either. Skin tones and pale colors can still shift, so inspect faces and charts at full size.
Is Ghostscript free to use?
Ghostscript is free to install and use under its license. The standard distribution is AGPL, and Artifex sells commercial licenses for cases that cannot comply. If you embed it in a product, read the license before you ship. For a personal script, the free route is fine.
Can I undo a permanent dark PDF?
Only if you keep the original. The pipeline writes new pixels and does not store a reversible theme setting. Keep input.pdf next to input-dark.pdf, and rerun from the original if you need a light copy. Do not overwrite the only copy.
Does dark mode save printer ink?
No. A dark page covers more area with toner. It may be easier to read at night, but it is worse for printing. Keep the light original for paper and use the dark file on a screen.
Does this work on scanned PDFs?
Yes, the pixels can be inverted. The catch is that a scan has no text layer to preserve, and OCR on a dark page is harder. If the scan is faded or gray, clean up the scan first, then make the dark copy. If you need search, keep a light OCR copy as the source of truth.
Need a dark PDF without installing a toolchain?
Open PDF Dark Mode, process pages locally at 0 credits, and sign in to export a permanent file. Optional AI redesign uses 2 credits per page, with 2+3 free pages (4+6 credits).