How to generate PDF in Grayscale

by Hairil Hasyimi Bin Omar

A grayscale PDF is a type of PDF document where all the colors and shades are represented using shades of gray instead of full-color spectrum.

IronPDF offers the functionality to render PDF documents in grayscale instead of colors. Printing PDF documents in grayscale is cost-effective for large batch printing. Additionally, rendering in grayscale enhances readability, particularly when the original colors are excessively bright or vibrant. Furthermore, grayscale PDFs enjoy increased compatibility across a wide range of devices, software, and platforms, ensuring consistent viewing and printing experiences across different systems.




C# NuGet Library for PDF

Install with NuGet

Install-Package IronPdf
or
Java PDF JAR

Download DLL

Download DLL

Manually install into your project

C# NuGet Library for PDF

Install with NuGet

Install-Package IronPdf
or
Java PDF JAR

Download DLL

Download DLL

Manually install into your project

Start using IronPDF in your project today with a free trial.

First Step:
green arrow pointer

Check out IronPDF on Nuget for quick installation and deployment. With over 8 million downloads, it's transforming PDF with C#.

C# NuGet Library for PDF nuget.org/packages/IronPdf/
Install-Package IronPdf

Consider installing the IronPDF DLL directly. Download and manually install it for your project or GAC form: IronPdf.zip

Manually install into your project

Download DLL

Generate Grayscale PDF Example

To generate a grayscale PDF, you can set the GrayScale property of the RenderingOptions to true.

In the provided code snippet, we can see that the grayscale feature is enabled after instantiating a ChromePdfRenderer. It is then used to render a web page using the RenderUrlAsPdf method. The code snippet also includes extracting only the first page of the rendered PDF and saving it locally.

:path=/static-assets/pdf/content-code-examples/how-to/color-grayscale-grayscale.cs
using IronPdf;

ChromePdfRenderer renderer = new ChromePdfRenderer();

// Set GrayScale to true
renderer.RenderingOptions.GrayScale = true;

PdfDocument pdf = renderer.RenderUrlAsPdf("https://ironsoftware.com/");
pdf.CopyPage(0).SaveAs("test.pdf");
IRON VB CONVERTER ERROR developers@ironsoftware.com
VB   C#

Please note
The current implementation of the Grayscale feature will turn the text in the rendered PDF document into an image, resulting in the ExtractAllImages method not outputting any text.

Currently, this functionality is only available when rendering PDFs. In the future, it would be beneficial to have the ability to convert existing PDF documents to grayscale.

Hairil Hasyimi Bin Omar

Software Engineer

Like all great engineers, Hairil is an avid learner. He’s refining his knowledge of C#, Python, and Java, using that knowledge to add value to team members across Iron Software. Hairil joined the Iron Software team from Universiti Teknologi MARA in Malaysia, where he graduated with a Bachelor's degree in Chemical and Process Engineering.