Set to Grayscale
from ironpdf import *

renderer = ChromePdfRenderer()

# Set Color and Grayscale
renderer.RenderingOptions.GrayScale = True

renderer.RenderHtmlFileAsPdf("my-content.html").SaveAs("my-content.pdf")
pip install ironpdf
Set to Grayscale

Set to Grayscale

IronPDF for Python can render PDFs entirely in grayscale by setting a single property on RenderingOptions, converting all colors in the source HTML to shades of gray in the output.

Getting Started

Set RenderingOptions.GrayScale = True on a ChromePdfRenderer instance before calling any render method. All subsequent PDFs produced by that renderer will be rendered in grayscale.

Understanding the Code

  • GrayScale = True: Instructs IronPDF to convert all colors in the rendered output to grayscale. This applies to text, backgrounds, borders, images, and any other colored elements in the HTML source.
  • RenderHtmlFileAsPdf("my-content.html"): Renders the local HTML file using the grayscale setting.
  • SaveAs("my-content.pdf"): Saves the grayscale PDF to disk.

Use Cases

Grayscale rendering is useful when:

  • Reducing file size - grayscale PDFs are typically smaller than color equivalents.
  • Ensuring print consistency - documents intended for black-and-white printers look identical on screen and in print.
  • Meeting accessibility requirements - some accessibility standards require documents to remain legible when color is removed.

To render only specific pages in grayscale, render them separately with GrayScale = True and merge the result with full-color pages using PdfDocument.Merge.

Ready to Get Started?

Version:2026.11just released