Notes written on a dark page look good on a screen. Printing them is another story. A black page uses a lot of ink, and recoloring a few hundred pages by hand is not something anyone wants to do.
The obvious fix is to invert the colors, but inversion keeps the dark paper dark in a different way. A charcoal page with a luminance of 28 becomes 227 after inversion, which prints as a light gray wash over the whole sheet. A filter that inverts by 86 percent leaves the same page at 199.
A white point instead of an inversion
Stingier treats the paper color as the white point. For each page it finds the most common luminance, calls that B, and maps every pixel with luminance Y to
255 * (1 - clamp((Y - B - t) / (255 - B - t) * gain, 0, 1))
t is a small tolerance for noise. Anything at or below the paper level comes out 255, white ink comes out 0, and light ink lands in between. A box drawn around a photo skips the formula, so the picture keeps its colors.
One file, nothing uploaded
The tool is a single HTML file of about 1.8 MB. pdf.js renders the pages, the page converts them, and a small PDF writer saves a flattened copy. A Content Security Policy blocks network connections, and a test checks that a fetch from the page fails.
What I measured
I generated five synthetic dark pages (paper levels 0, 28, 28 with noise, 28 with a picture and 50), exported them through the page, rasterized the result with poppler and counted the pixels in labelled blank margins. All 2,018,940 of them came out at RGB 255. The numbers for plain inversion and the Veil export filter are arithmetic from their formulas, not runs of those tools.
What is rough
The output is flattened, so text, links and forms are gone from the print copy. The paper estimate can be fooled by ruled templates or colored margins. I have only tested synthetic pages and Chromium. Exports from real note apps are the thing I most want to see.
The code, tests and the demo are at https://github.com/Arthur031221/stingier.

Top comments (0)