# Changing Block's Text Color in PDF Documents Using RadPdfProcessing

## Environment

| Version     | Product          | Author                                                                          |
| ----------- | ---------------- | ------------------------------------------------------------------------------- |
| 2024.4.1106 | RadPdfProcessing | [Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova) |

## Description

When working with PDF documents using [RadPdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/overview), you can change the foreground color of the text inside a table to differentiate between various pieces of information, such as an account number and its value. This knowledge base article also answers the following questions:

* How to change the text color within a PDF table using RadPdfProcessing?
* How to differentiate text elements in a PDF document by color?
* How to apply foreground colors to the text of Blocks within a PDF table?

## Solution

To change the text color inside a table in a PDF document using RadPdfProcessing, use the `FillColor` property of [GraphicProperties](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/text-and-graphic-properties). This property controls the color used for drawing the content elements of a `Block`. You can temporarily change the graphic properties for specific text elements by using the `SaveGraphicProperties()` and `RestoreGraphicProperties()` methods. This allows you to apply different colors, at different stages, to different parts of the text inside a table cell.

The following steps describe how to achieve this:

1. Create a [PDF Table](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/overview) and add a [PDF Table Row](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablerow) and a [PDF Table Cell](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablecell) to it.
2. Add a [Block](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/block) to the cell for the text you want to display.
3. Use `SaveGraphicProperties()` to save the current graphic state.
4. Set the [FillColor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/concepts/colors-and-color-spaces) property of [GraphicProperties](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/text-and-graphic-properties) to the desired color.
5. Insert the text into the block.
6. Use `RestoreGraphicProperties()` to revert to the previous graphic state.
7. Repeat steps 2–6 for any additional text blocks with different colors.

```csharp
Table table = new Table();
table.LayoutType = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.TableLayoutType.FixedWidth;

TableRow row = table.Rows.AddTableRow();
TableCell cell = row.Cells.AddTableCell();

// First text block
Block block = cell.Blocks.AddBlock();
block.SaveGraphicProperties();
block.GraphicProperties.FillColor = new RgbColor(0, 0, 255); // Blue color for "Account No."
block.InsertText("Account No.");
block.RestoreGraphicProperties();

// Second text block
block = cell.Blocks.AddBlock();
block.SaveGraphicProperties();
block.GraphicProperties.FillColor = new RgbColor(0, 255, 0); // Green color for the account number value
block.InsertText("12345678910");
block.RestoreGraphicProperties();
```

![Change Text Color in PDF](https://www.telerik.com/document-processing-libraries/documentation/assets/f8b286645a1a63c658b9c3b438fc0d24/change-text-color-pdf-radpdfprocessing.png)

Use these steps to differentiate text elements in a PDF document with different foreground colors.

## See Also

* [Text and Graphic Properties in RadPdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/text-and-graphic-properties)
* [Block Content in RadPdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/block)
* [Colors and Color Spaces](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/concepts/colors-and-color-spaces)
