---
title: "Update Text And Shape Color"
canonical: https://www.graphicsmill.com/samples/PSDFormat/RenderTemplates/UpdateTextAndShapeColor_cs
product: "Graphics Mill"
source: "PSDFormat/RenderTemplates/UpdateTextAndShapeColor.cs"
---

# Update Text And Shape Color

Updates text and shape color of PSD image and saves to PDF file.

## Instruction

Write a C# program that modifies "Seal.psd" using PSD processor with dual callbacks: TextCallback to update text content with custom string, apply DarkRed SolidBrush fill while preserving original text frame properties via processor.ProcessText, and FrameCallback to detect shape frames, create GraphicsContainer matching shape bounds/DPI, fill VectorMask path with DarkGreen SolidBrush using AdvancedGraphics, then render combined modifications to PDF "UpdateTextAndShapeColor.pdf" while preserving other layers unchanged.

## Usings

```csharp
using Aurigma.GraphicsMill.Codecs.Psd;
using Aurigma.GraphicsMill.Drawing;
using Aurigma.GraphicsMill.Templates;
```

## Code Snippet

```csharp
var psdProcessor = new PsdProcessor();

var psName = psdProcessor.FontResolver.FontRegistry.Add("ARIALUNI.TTF")[0].PostscriptName;
psdProcessor.FontResolver.FontRegistry.FallbackFonts.Add(psName);

psdProcessor.TextCallback = (processor, textFrame, textString) =>
{
    var text = processor.ProcessText(textFrame);
    text.String = textString;

    text.Brush = new SolidBrush(RgbColor.DarkRed);

    return text;
};

psdProcessor.FrameCallback = (processor, frame) =>
{
    if (frame.Type != FrameType.Shape)
    {
        return processor.ProcessFrame(frame);
    }

    var shapeFrame = (PsdShapeFrame)frame;

    var graphicsContainer = new GraphicsContainer(frame.X + frame.Width, frame.Y + frame.Height, frame.DpiX, frame.DpiY);

    using (var graphics = graphicsContainer.GetGraphics())
    {
        graphics.FillPath(new SolidBrush(RgbColor.DarkGreen), shapeFrame.VectorMask);
    }

    return graphicsContainer;
};

psdProcessor.Render("Seal.psd", "UpdateTextAndShapeColor.pdf");
```

## Explanation

Below is a C# code sample that updates both text content/color and vector shape fills in PSD:

The code demonstrates advanced PSD modification using dual callbacks: TextCallback intercepts text rendering to customize content, apply DarkRed brush while maintaining original typography via processor.ProcessText; FrameCallback targets shape layers, extracts VectorMask paths, creates dimension-matched GraphicsContainer, and fills shapes with DarkGreen SolidBrush for color customization. This pattern enables complete design template personalization - updating both typographic content/color and vector graphics fills - supporting dynamic seal/logo generation, certificate customization, and variable data workflows with preserved layer structure and professional PDF output.

## Tags

- [Personalization](<https://www.graphicsmill.com/samples/tags/personalization_md>): Replacing placeholders with dynamic content
- [PSD Processor](<https://www.graphicsmill.com/samples/tags/psd-processor_md>): Automating PSD-based personalization

## Input

- [Seal.psd](<https://www.graphicsmill.com/samples/PSDFormat/compiled/Debug/Seal_psd>) (download)

## Output

- [UpdateTextAndShapeColor.pdf](<https://www.graphicsmill.com/samples/PSDFormat/compiled/Debug/UpdateTextAndShapeColor_pdf>) (download)
- [UpdateTextAndShapeColor.png](<https://www.graphicsmill.com/samples/PSDFormat/compiled/Debug/UpdateTextAndShapeColor_png>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Codecs.Frame.DpiX](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_Frame_DpiX.htm.md>)
- [Aurigma.GraphicsMill.Codecs.Frame.DpiY](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_Frame_DpiY.htm.md>)
- [Aurigma.GraphicsMill.Codecs.Psd.FrameType](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_Psd_FrameType.htm.md>)
- [Aurigma.GraphicsMill.Codecs.Psd.PsdFrame.Type](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_Psd_PsdFrame_Type.htm.md>)
- [Aurigma.GraphicsMill.Codecs.Psd.PsdFrame.VectorMask](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_Psd_PsdFrame_VectorMask.htm.md>)
- [Aurigma.GraphicsMill.Codecs.Psd.PsdFrame.X](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_Psd_PsdFrame_X.htm.md>)
- [Aurigma.GraphicsMill.Codecs.Psd.PsdFrame.Y](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_Psd_PsdFrame_Y.htm.md>)
- [Aurigma.GraphicsMill.Codecs.Psd.PsdShapeFrame](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_Psd_PsdShapeFrame.htm.md>)
- [Aurigma.GraphicsMill.Drawing.CustomFontRegistry.Add(String)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_CustomFontRegistry_Add_1_bb3a7a4f.htm.md>)
- [Aurigma.GraphicsMill.Drawing.FontAddResult.PostscriptName](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_FontAddResult_PostscriptName.htm.md>)
- [Aurigma.GraphicsMill.Drawing.FontRegistry.FallbackFonts](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_FontRegistry_FallbackFonts.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.FillPath(Brush,Path)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_FillPath_2_3cee1596.htm.md>)
- [Aurigma.GraphicsMill.Drawing.GraphicsContainer](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_GraphicsContainer.htm.md>)
- [Aurigma.GraphicsMill.Drawing.GraphicsContainer.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_GraphicsContainer_GetGraphics.htm.md>)
- [Aurigma.GraphicsMill.Drawing.SolidBrush](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_SolidBrush.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Text.Brush](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Text_Brush.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Text.String](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Text_String.htm.md>)
- [Aurigma.GraphicsMill.Templates.FontResolver.FontRegistry](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Templates_FontResolver_FontRegistry.htm.md>)
- [Aurigma.GraphicsMill.Templates.PsdProcessor](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Templates_PsdProcessor.htm.md>)
