---
title: "Loading Text Layers"
canonical: https://www.graphicsmill.com/docs/gm5/LoadingTextLayers.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# Loading Text Layers
 
In addition to raster layers, Advanced PSD Add-on for Graphics Mill can work with text layers. These layers keep not only bitmap but also a text string and its appearance settings (font, color, paragraph). It is very convenient if you store templates in PSD files and use text layers as placeholders. So you can change the text in these placeholder when merging the PSD file and create personalized graphics this way.
 
## Class Structure
  
The main class you should use to load layers with Advanced PSD Add-on is [Aurigma.GraphicsMill.Codecs.AdvancedPsdReader](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_AdvancedPsdReader.htm.md) . Text layers are represented by the [Aurigma.GraphicsMill.Codecs.AdvancedPsdTextFrame](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_AdvancedPsdTextFrame.htm.md) class (inherited from [Aurigma.GraphicsMill.Codecs.AdvancedPsdFrame](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_AdvancedPsdFrame.htm.md) class).
 
## Extract Text from Layer
  
To get text layers, you should work with the advanced PSD reader in the same way as described in the [Loading Raster Layers](https://www.graphicsmill.com/docs/gm5/LoadingRasterLayers.htm.md) section. When you iterate through PSD layers, you should verify whether the current layer is text or not. For this purpose check the [AdvancedPsdFrame.Type](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_AdvancedPsdFrame_Type.htm.md) property. If the type of the layer is [Text](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_PsdFrameType.htm.md) you should cast the current frame to the AdvancedPsdTextFrame class. This class exposes all properties necessary to get information about the text layer. These properties are:
 
- [Color](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_AdvancedPsdTextFrame_Color.htm.md) property - the color of the text. If you need to draw the text string with the [GdiGraphics.DrawString](https://www.graphicsmill.com/docs/gm5/O_T_Aurigma_GraphicsMill_Drawing_GdiGraphics_DrawString.htm.md), you can use the [TextBrush](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_AdvancedPsdTextFrame_TextBrush.htm.md) property instead;
- [FirstLineIndent](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_AdvancedPsdTextFrame_FirstLineIndent.htm.md) property - the margin of the first line in the paragraph;
- [LeftIndent](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_AdvancedPsdTextFrame_LeftIndent.htm.md) property - the margin from the left;
- [RightIndent](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_AdvancedPsdTextFrame_RightIndent.htm.md) property - the margin from the right;
- [Font](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_AdvancedPsdTextFrame_Font.htm.md) property - the font name of the text;
- [Justification](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_AdvancedPsdTextFrame_Justification.htm.md) property - the text alignment;
- [SpaceAfterParagraph](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_AdvancedPsdTextFrame_SpaceAfterParagraph.htm.md) property - the interval after the paragraph;
- [SpaceBeforeParagraph](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_AdvancedPsdTextFrame_SpaceBeforeParagraph.htm.md) property - the interval before the paragraph;
- [Text](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_AdvancedPsdTextFrame_Text.htm.md) property - the text string itself;
- [TextBox](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_AdvancedPsdTextFrame_TextBox.htm.md) property - the text boundaries.

Let's consider the example where we log the PSD layers settings into a text file. The following code snippet demonstrates how to do it:
 
```
' Create advanced PSD reader object to work with PSD files.
Dim psdReader As New Aurigma.GraphicsMill.Codecs.AdvancedPsdReader

' Create advanced PSD text frame object to be able to work with text layers.        
Dim textFrame As New Aurigma.GraphicsMill.Codecs.AdvancedPsdTextFrame

' Open advanced PSD reader to be able to get layers.
psdReader.Open("C:\Temp\WorkingWithLayers.psd")

' This code creates text file and saves layers' settings into it.
Dim resultFile As New System.IO.StreamWriter("C:\Temp\PsdLayersDescription.txt")

Dim frame As Aurigma.GraphicsMill.Codecs.AdvancedPsdFrame
For Each frame In psdReader

    ' Write the number and the type of the layer.
    resultFile.WriteLine("-------------------")
    resultFile.WriteLine("frame_{0}", frame.Index)
    resultFile.WriteLine("Type: {0}", frame.Type)

    ' Check out the layer type.
    Select Case (frame.Type)

        ' If the layer is text then output text string, 
        ' font type and font size of the text sting.
    Case Aurigma.GraphicsMill.Codecs.PsdFrameType.Text
            textFrame = frame
            resultFile.WriteLine("String: {0}", textFrame.Text)
            resultFile.WriteLine("Font Name: {0}", textFrame.Font.Name)
            resultFile.WriteLine("Font Size: {0}", textFrame.Font.Size)

            ' If the layer is raster then output width and height of the layer.
        Case Aurigma.GraphicsMill.Codecs.PsdFrameType.Raster
            resultFile.WriteLine("Width: {0}", frame.Width)
            resultFile.WriteLine("Height: {0}", frame.Height)

            resultFile.WriteLine("")

    End Select
Next

' Clean up.
psdReader.Close()
resultFile.Close()
```
 
```csharp
// Create advanced PSD reader object to work with PSD files.
Aurigma.GraphicsMill.Codecs.AdvancedPsdReader psdReader = 
    new Aurigma.GraphicsMill.Codecs.AdvancedPsdReader();

// Create advanced PSD text frame object to be able to work with text layers.        
Aurigma.GraphicsMill.Codecs.AdvancedPsdTextFrame textFrame;

// Open advanced PSD reader to be able to get layers.
psdReader.Open(@"C:\Temp\WorkingWithLayers.psd");

// This code creates text file and saves layers' settings into it.
using (System.IO.StreamWriter resultFile = new System.IO.StreamWriter(@"C:\Temp\PsdLayersDescription.txt")) 
{
    foreach (Aurigma.GraphicsMill.Codecs.AdvancedPsdFrame frame in psdReader)
    {
        // Write the number and the type of the layer.
        resultFile.WriteLine("-------------------");
        resultFile.WriteLine("frame_{0}", frame.Index);
        resultFile.WriteLine("Type: {0}", frame.Type);
        
        // Check out the layer type.
        switch(frame.Type)
        {
            // If the layer is text then output text string, 
            // font type and font size of the text string.
            case Aurigma.GraphicsMill.Codecs.PsdFrameType.Text:
                textFrame = (Aurigma.GraphicsMill.Codecs.AdvancedPsdTextFrame)frame;
                resultFile.WriteLine("String: {0}", textFrame.Text);
                resultFile.WriteLine("Font Name: {0}", textFrame.Font.Name);
                resultFile.WriteLine("Font Size: {0}", textFrame.Font.Size);
                break;
            
            // If the layer is raster then output width and height of the layer.
            case Aurigma.GraphicsMill.Codecs.PsdFrameType.Raster:
                resultFile.WriteLine("Width: {0}", frame.Width);
                resultFile.WriteLine("Height: {0}", frame.Height);
                break;
        }
        resultFile.WriteLine("");
    }
 }

// Clean up.
psdReader.Close();
```
 
## See Also
  
### Manual
 
- [Loading Raster Layers](https://www.graphicsmill.com/docs/gm5/LoadingRasterLayers.htm.md)
- [Merging Layers](https://www.graphicsmill.com/docs/gm5/MergingLayers.htm.md)
