grayscale
Grayscale PDF
Take the colour out of a document, so it prints in black and white.
- Reads
- a PDF — application/pdf
- Writes
- one file — PDFs
- Tool page
- /grayscale-pdf
Example
Take the colour out of a document that is going to a mono printer.
Given
- illustrated.pdf — a PDF with a photograph in it
From code
import { loadDocument, runOperation } from '@pagecraft/core';
const illustrated = await loadDocument({ bytes, name: 'illustrated.pdf' });
const [output] = await runOperation('grayscale', [illustrated]);
From a shell
pagecraft grayscale illustrated.pdf
What comes back
One PDF of 1 page.
This example is run by the test suite. If it stopped being true, the build would fail.
Options
This operation takes no options.
What it cannot do
- A photograph stored as a JPEG comes back a JPEG with every pixel neutral. It still carries three channels, because no browser codec writes a one-channel JPEG — storing it uncompressed instead would be several times the size.
- Named inks, patterns and shadings are left as they are. Guessing at the grey each was meant to be is how a print job comes back wrong, so the report says when one was met instead.
- An image written into the page itself, rather than stored beside it, is left in colour.
- Colours are converted with the standard luma weights and no colour management, which is what a viewer with no profile shows.