Dark mode that travels with the file
Plenty of PDF readers offer a night mode, and for a single device it is the easier answer. The catch is that it is a viewing filter. It lives in that app’s settings, applies while you look at the page and is gone the moment the document is opened somewhere else, emailed to a colleague, loaded onto an e-reader that has no such setting, or printed.
Inverting the file writes the change into the document. A white page with black type becomes a dark page with light type in every viewer, on every device, permanently, because the pages have genuinely changed rather than being recolored on their way to the screen. That is a strange thing to want for an archival document and exactly the right thing for the copy of a textbook chapter you read in bed.
The arithmetic itself is trivial. Each red, green and blue channel is replaced by 255 minus its old value, the same helper that powers invert-image for photographs. What makes a document harder than a photograph is that a blind inversion also flips every picture on the page into a negative, and a page of otherwise readable notes with a livid blue face staring out of it is worse than the bright original.
Inside smart mode: operator lists, matrices and unit squares
A PDF page is a program. It places an embedded image by building up a transformation matrix through a sequence of transform operators, then painting the image into the unit square, which the matrix stretches and moves into position. Smart mode replays that program without drawing anything, keeping a stack for the save and restore operators so nested transforms unwind properly, and every time an image painting operator appears it takes the current matrix, pushes the four corners of the unit square through it, then through the renderer’s own page to pixel matrix, and records the box that encloses them.
That is computed from the document’s own placement data rather than guessed from what the pixels look like, which is why a night sky and a beach are found the same way. It is exact for an image the page places directly; one nested inside a reusable form object that carries its own matrix is located from the page level placement alone, so its box can land beside the picture rather than on it, and because that object’s own transforms are not unwound when it ends, a later picture on the same page can be shifted too. The page is then inverted in full, and each of those recorded rectangles is copied back from a snapshot taken before the inversion, which is why a photo comes out looking normal while the paper around it goes dark.
The boundaries are rounded outward rather than to the nearest pixel. That choice guarantees an image never loses its own edge row, at the cost of occasionally carrying a hairline of surrounding page into the protected box.
Two image operators that stay inverted on purpose
Not every image on a page is a photograph, and two cases are deliberately left out of the detection rather than half handled.
The first is the stencil mask, a one bit image painted in the current fill color. Scanned monochrome text and many logos arrive this way, and because such an image takes its color from the graphics state it behaves like type rather than like a picture. Sparing it would leave black marks on a black background. It is inverted with everything else.
The second is the repeated image, a single picture tiled several times through a pattern fill, where each repetition carries its own transform inside an argument structure the detector does not unpack. It is rare, and when it does appear its content simply inverts along with the page instead of being reverse engineered.
Turning a document dark, one option at a time
- Drop your PDF onto the box above or press Choose a file. One document per run.
- Leave Keep photos & images un-inverted (smart mode) ticked, which is the default, so pictures keep their real colors. Unticking it inverts the whole page with no exceptions, which is what you want for a document whose only images are diagrams that read better reversed.
- Set Output quality. Standard (150 DPI), recommended is ample for reading on a screen, Print quality (300 DPI), best for a professional print run doubles the linear detail and so quadruples the pixels, the memory and the time, and Smaller file (100 DPI) keeps a phone copy light.
- Press Invert PDF Colors (Dark Mode PDF) and watch the progress climb page by page, the last stretch being the assembly of the new document.
- Download the file, which arrives with
-invertedadded to the name, sonotes.pdfbecomesnotes-inverted.pdf.
Picking a resolution for a screen you read in the dark
The resolution ladder is shared with grayscale-pdf, which renders through the same code, and the same reasoning applies with one twist. Reading happens on a screen, and a phone or tablet displaying a page at fit to width is nowhere near using the detail that Print quality produces, so Standard is usually the sharpest setting anyone will actually see.
Where the twist bites is compression. An inverted page is dominated by a large flat dark area, and every page is stored as a JPEG, so pushing the quality down to Smaller file puts the coarsest compression against the least forgiving background. If a dark page looks blotchy behind the text, that is the setting to raise first.
What an inverted copy is not good for
The pages you get back are pictures. The new document is assembled from scratch around those images, so selectable text, search, links, bookmarks, comments and form fields are all absent from it, and its page dimensions are the only thing carried over from the original. Treat the inverted file as a reading copy and keep the source for everything else.
A document that needs a password to open cannot be inverted here, because nothing in the tool ever asks you for one. A file carrying only an owner password, which restricts printing or copying rather than opening, is read with the empty password and inverts normally. If the finished file is heavier than you want on a phone, the pages are already images, so the lossless clean up in compress-pdf has little left to strip and its strong mode, which re-renders the pages, is the one that helps. And if what you actually wanted was dark slides rather than a dark document, run the inverted file through pdf-to-jpg to get one image per page, with the rest of the workflow waiting in the PDF tools.

