PDF to Grayscale (or Black and White)
Operator: Abdulla Al Fahad. How tools are built and checked
Colour in a PDF costs money the moment it is printed. A letter with a coloured logo, a brochure with tinted panels or a scan with a yellowed background all draw on colour toner or ink, and a photocopier asked for black and white may turn a pale panel into dark blotches. Converting the PDF to grayscale first lets you see exactly what the printer will get.
Two conversions are offered. Grayscale keeps 256 shades of grey and suits photographs and shaded charts. Black and white keeps only black and white, with a cut you set, and suits forms, contracts and scanned text where you want solid black letters on clean white paper. In both, every page you convert is redrawn as a picture. The page says so beside the button because it changes what the file can do afterwards.
Key features
- Grayscale (8-bit, JPEG) or black and white (true 1-bit) conversion
- Threshold slider from 20 to 235, plus a button that proposes a value from the page you are looking at (Otsu's method)
- Resolution choice of 100, 150, 200 or 300 DPI with automatic lowering for very large pages
- Page range, with the other pages kept in colour or left out
- Side-by-side before and after of any page you choose, redrawn when you move a control
- File size of the previewed page, an estimate for the whole run, and the real size afterwards
- Progress per page and a Cancel button
Grayscale, 1-bit black and white, and why the pages become images
The page range accepts the usual forms, such as 1-3, 5, 8- or all, and an empty box means every page; up to 400 pages are converted per run. The PDF can be up to 50 MB and must open without a password.
Each selected page is drawn by pdf.js at 100, 150, 200 or 300 DPI as the page is displayed, with its rotation applied, onto white. The longest side is capped at 5,000 pixels and the whole canvas at 16 million pixels, because Safari refuses canvases above 16.7 million. When a page would exceed either cap the DPI is lowered just enough for that page, and a note after the run says how many pages were affected. The new page has exactly the same width and height in points as the page appeared before conversion, so a rotated or cropped page keeps its look.
Luminance is worked out with the weights 0.299 for red, 0.587 for green and 0.114 for blue, rounded to a whole number. Grayscale writes that value into all three channels and stores the page as a JPEG at the quality you set, from 40 to 95 with 80 as the default. Black and white compares the luminance with the threshold, from 20 to 235 with 128 as the default: darker becomes black, everything else white. The result is stored as a real one-bit-per-pixel image, packed eight pixels to a byte and compressed with Flate, not as an 8-bit image that happens to hold two values.
Pages outside the range can either be left out or kept exactly as they were, in colour with their text intact; kept pages stay in their original positions in the output. Title and author are carried over only when some pages are kept, because only then is the original opened for editing. Bookmarks, links and form fields on a converted page are not preserved, since the page is now a single picture. The output is named after the original with -grayscale or -black-and-white added.
How it works
The preview draws your chosen page once at the selected DPI and keeps it. Moving the threshold or quality slider only reprocesses that kept drawing, after a quarter-second pause so a drag does not queue work. Changing the DPI or the preview page draws the page again.
The size shown for the page is not a guess. The tool builds a one-page PDF from the converted preview with the same code the full run uses, saves it, and reports its byte length. The whole-file estimate multiplies that by the number of pages in your range, which is why it says about.
The suggested threshold comes from Otsu's method on the preview page's luminance histogram: it picks the cut that best separates a dark group of pixels from a light group. When the histogram has a flat gap between the two groups, many cuts tie, and the middle of the gap is chosen.
Common use cases
- Printing a colour contract on an office laser printer where only black toner is loaded
- Preparing a scanned form for a photocopier that makes pale tints muddy
- Making a 40-page colour manual cheaper to print by converting only the text pages and keeping the diagrams in colour
- Producing a clean black and white copy of a phone-camera scan, with the threshold set to drop the yellow paper tone
How to use this tool
- Choose the PDF. The first page appears on the right as Original and as the converted version.
- Pick Grayscale or Black and white. For black and white, drag the threshold until thin text is solid but the background stays white, or press the suggested value.
- Choose a resolution. 150 DPI is fine for reading, 200 for a laser printout, 300 for fine print.
- Type a page range if you only need some pages, and decide whether the others are kept or left out. Use the preview page box to inspect a page that looks different from the first.
- Check the size line, then press Convert. The converted PDF downloads when the last page is done.
Example
A 12-page A4 brochure converted to black and white at 200 DPI, and an A3 poster at 300 DPI
A4 page 595.28 x 841.89 pt
Drawing at 200 about 1,654 x 2,339 px (3.87 million pixels)
Packed 1-bit 207 bytes per row x 2,339 rows = 484,173 bytes before Flate
A3 poster 842 x 1,191 pt, asked for 300 DPI -> 3,508 x 4,963 px = 17.4 million pixelsWhat the tool does
A4 page stored as a 1-bit image, then compressed; the preview reports the real size and x12 is the estimate
A3 poster over the 16 million pixel cap, so the DPI is lowered by 4% to about 288
the note after the run says one page was drawn at a lower resolutionTips for best results
- For a scan of a text document, black and white at 200 DPI is usually both the smallest and the sharpest option. Use grayscale instead when the page has photographs.
- If thin letters break up in black and white, raise the threshold a few steps at a time and watch the preview; if the background starts to speckle, you have gone too far.
- Compare file sizes between 150 and 200 DPI on your own preview page before committing; the jump is often smaller than people expect for black and white and larger for grayscale photos.
- Use the range box to convert only the pages that need it and choose to keep the rest. Text pages that stay as they are remain searchable.
- The preview image is scaled to fit the panel, so judge fine detail at your printer's real size, not on the thumbnail.
Edge cases to watch
Converted pages are pictures. Their text can no longer be selected, searched, copied or read aloud, and screen readers get nothing. If you need a searchable copy, keep the original, or run OCR on the result.
A very small threshold turns most of a page white and a very large one turns it black; neither is an error. The preview shows the result before you convert.
The file can come out larger than the original. A mostly-text PDF holds compact vector text, and a picture of the same page at 200 DPI is heavier even in 1 bit. The estimate line warns you before the run.
Black and white removes shading: a light grey table row or a tinted chart area can vanish entirely or turn solid black, depending on the threshold.
Links, bookmarks and form fields on converted pages are gone, because the page is now one image. Pages you keep outside the range are copied normally.
Common errors and how to fix them
- "This PDF is password-protected."
- Open it with the password in a viewer and save an unprotected copy, or use an unlock tool, then convert that copy.
- "This tool converts up to 400 pages per run; the range holds 520."
- Type a smaller range, such as 1-400, run it, then do the rest as a second file. Pages are held in memory while the new document is built.
- "Page 7 could not be converted"
- That page failed to draw, often because of a damaged image. Exclude it from the range and choose to keep the other pages, or repair the PDF in a viewer first.
- The range box shows a red message about a page that does not exist
- The number is above the page count shown beside the file name. Correct it; nothing is converted until the range is valid.
Best practices
- Choose the preview page that is hardest to read, such as a page with a stamp or a light table, and tune the threshold there.
- Pick the lowest DPI that still looks right at print size; every step up costs file size and conversion time.
- Keep the original colour PDF. This conversion is one way.
Grayscale is not the same as black and white
A grayscale page still has soft edges: the curve of a letter is made of grey pixels of varying darkness, and a photograph keeps its tones. That is why it is stored as a JPEG, which is efficient for smooth tones. The price is that scanned text can pick up faint speckles around the letters at low quality settings. Black and white has no grey at all. Edges are hard, which prints crisply, but any detail between the dark and light groups is forced to one side.
Because the one-bit image holds a single bit per pixel, a page at 200 DPI needs about 484 KB before compression, against 3.9 MB for the same page in 8-bit grey. After compression, large flat areas of white shrink to almost nothing, which is why black and white scans of text come out small.
Choosing a threshold
The threshold is a luminance level. A mid-grey of 128 is the usual start, but a scan of grey recycled paper may have a background near 170, which would sit on the wrong side of a high threshold and turn solid black. Reading the preview is the quickest test: the background should be pure white, and the thinnest letters should still be unbroken.
The suggested value is computed from the page you are previewing, not from the whole file. Pages with different paper or lighting may need another value, which is a good reason to flip the preview page box through two or three pages before converting.
Frequently asked questions
Why can't I select the text after converting?
Each converted page is stored as a picture of the page. The tool does not recognise text, so it has none to keep. Pages outside the range that you choose to keep are copied as they were and stay selectable.
Does the PDF leave my device?
No. The pages are drawn, converted and assembled in this browser tab, and the new file is saved from there.
Is the black and white output really one bit?
Yes. Pixels are packed eight to a byte in a DeviceGray image with one bit per component and compressed with Flate, so the file holds only black and white and is far smaller than an 8-bit picture of the same page.
Why is my A3 page at a lower resolution than I chose?
The canvas used for drawing is capped at 16 million pixels so that Safari and phones can handle it. A page that would need more is drawn at a slightly lower DPI and the result note tells you so.