# Convert to grayscale Convert PDFs to grayscale to reduce file size and speed up printing using the GroupDocs.Viewer Python API. To speed up the printing of a PDF file and reduce its size, you can convert it from RGB color space to grayscale. To convert a PDF file to grayscale, set the [convert_to_gray_scale](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfoptimizationoptions/#properties) property to `True`. The following code snippet shows how to convert a PDF file to grayscale: {{< tabs "Example1">}} {{< tab "Python" >}} ```python from groupdocs.viewer import Viewer from groupdocs.viewer.options import PdfViewOptions, PdfOptimizationOptions def convert_to_grayscale(): # Load document with Viewer("sample.docx") as viewer: viewOptions = PdfViewOptions("convert_to_grayscale/grayscale_output.pdf") viewOptions.pdf_optimization_options = PdfOptimizationOptions() viewOptions.pdf_optimization_options.convert_to_gray_scale = True viewer.view(viewOptions) if __name__ == "__main__": convert_to_grayscale() ``` {{< /tab >}} {{< tab "sample.docx" >}} {{< tab-text >}} `sample.docx` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/python-net/_sample_files/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/optimization-pdf-convert-grayscale/sample.docx) to download it. {{< /tab-text >}} {{< /tab >}} {{< tab "grayscale_output.pdf" >}} ```text Binary file (PDF, 1.3 MB) ``` [Download full output](https://docs.groupdocs.com/viewer/python-net/_output_files/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-images/optimization-pdf-convert-grayscale/convert_to_grayscale/grayscale_output.pdf) {{< /tab >}} {{< /tabs >}}