---
title: "Update Text"
canonical: https://www.graphicsmill.com/samples/PSDFormat/RenderTemplates/UpdateText_cs
product: "Graphics Mill"
source: "PSDFormat/RenderTemplates/UpdateText.cs"
---

# Update Text

Updates text layer of PSD image and saves to PDF file.

## Instruction

Write a C# program that updates text content in "BusinessCard.psd" using PSD processor's StringCallback to intercept text frame processing, retrieve current formatted text via GetFormattedText, conditionally replace content for text frame named "Name" with "Type your name", and render the modified PSD with updated text layer to PDF "UpdateText.pdf" while preserving all other layers, styling, and formatting.

## Usings

```csharp
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.StringCallback = (processor, textFrame) =>
{
    var textString = textFrame.GetFormattedText();

    if (textFrame.Name == "Name")
    {
        textString = "Type your name";
    }

    return textString;
};

psdProcessor.Render("BusinessCard.psd", "UpdateText.pdf");
```

## Explanation

Below is a C# code sample that dynamically updates PSD text layers:

The code demonstrates PSD text layer modification using StringCallback to intercept text frame rendering, selectively updating content based on layer name ("Name" → "Type your name") while preserving original text formatting, font, styling, and positioning. GetFormattedText retrieves the complete styled text content, enabling template-based personalization workflows where dynamic text replacement maintains typographic fidelity and layer relationships. Non-text layers render unchanged, supporting business card templates, certificates, and automated document generation with variable data substitution.

## 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

- [BusinessCard.psd](<https://www.graphicsmill.com/samples/PSDFormat/compiled/Debug/BusinessCard_psd>) (download)

## Output

- [UpdateText.pdf](<https://www.graphicsmill.com/samples/PSDFormat/compiled/Debug/UpdateText_pdf>) (download)
- [UpdateText.png](<https://www.graphicsmill.com/samples/PSDFormat/compiled/Debug/UpdateText_png>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Codecs.Psd.PsdFrame.Name](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_Psd_PsdFrame_Name.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.Templates.FontResolver.FontRegistry](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Templates_FontResolver_FontRegistry.htm.md>)
- [Aurigma.GraphicsMill.Templates.PsdFrameExtensions.GetFormattedText(PsdTextFrame)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Templates_PsdFrameExtensions_GetFormattedText_1_05a2c2e1.htm.md>)
- [Aurigma.GraphicsMill.Templates.PsdProcessor](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Templates_PsdProcessor.htm.md>)
