ImageGear .NET v25.1 - Updated
Extract Text from DWG, DXF Formats
User Guide > How to Work with... > CAD > How To ... > Extract Text from DWG, DXF Formats

To extract text from a loaded DWG/DXF file, call ImGearDWGPage.ExtractText() and it returns a list of CADText objects.

Each CADText object contains the text and position of the text object.

The position is absolute and is based on the "world coordinates" of the DWG/DXF format. The position is stored in a double[3] and contains the x, y, z coordinates, respectively. 

Only text from the active layout will be extracted. See SetActiveLayout() for a look at how to change the layout that is currently active.
C#
Copy Code
using System.IO;
using System.Collections.Generic;
using ImageGear.Formats;
using ImageGear.Formats.CAD;

public static void ExtractTextFromCad(string path)
{
    ImGearDWGPage page = null;

    // Load the file.
    using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
    {
        page = (ImGearDWGPage)ImGearFileFormats.LoadPage(fileStream);
    }

    // Extract the text and use the returned list of CADText as desired.
    List<CADText> extractedText = page.ExtractText();
}
VB.NET
Copy Code
Imports System.IO
Imports System.Collections.Generic
Imports ImageGear.Formats
Imports ImageGear.Formats.CAD

Public Sub ExtractTextFromCad(path As String)
    Dim page As ImGearDWGPage

    ' Load the file.
    Using fileStream As New FileStream(path, FileMode.Open, FileAccess.Read)
        page = ImGearFileFormats.LoadPage(fileStream)
    End Using

    ' Extract the text and use the returned list of CADText as desired.
    Dim extractedText As List(Of CADText) = page.ExtractText()
End Sub