GemBox.Document is a .NET component that enables you to read, write, edit, convert, and print document files from your .NET applications using one simple API.

Get Content

Content of a document is represented with ContentRange class which is exposed on following members:

Following example demonstrates how to retrieve plain text representation of document elements by using ContentRange.ToString() method on their content.

Get Content Screenshot

See the full code below, use Run Example to execute.

Upload your file(Drag files here)

Download a sample file

using System;
using System.Text;
using System.Linq;
using GemBox.Document;

class Sample
    static void Main(string[] args)
        // If using Professional version, put your serial key below.

        DocumentModel document = DocumentModel.Load("Reading.docx");

        var sb = new StringBuilder();

        // Get content from each paragraph
        foreach (Paragraph paragraph in document.GetChildElements(true, ElementType.Paragraph))
            sb.AppendFormat("Paragraph: {0}", paragraph.Content.ToString());

        // Get content from each bold run
        foreach (Run run in document.GetChildElements(true, ElementType.Run))
            if (run.CharacterFormat.Bold)
                sb.AppendFormat("Bold run: {0}", run.Content.ToString());

Imports System
Imports System.Text
Imports System.Linq
Imports GemBox.Document

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.

        Dim document As DocumentModel = DocumentModel.Load("Reading.docx")

        Dim sb = New StringBuilder()

        ' Get content from each paragraph
        For Each paragraph As Paragraph In document.GetChildElements(True, ElementType.Paragraph)
            sb.AppendFormat("Paragraph: {0}", paragraph.Content.ToString())

        ' Get content from each bold run
        For Each run As Run In document.GetChildElements(True, ElementType.Run)
            If (run.CharacterFormat.Bold) Then
                sb.AppendFormat("Bold run: {0}", run.Content.ToString())
            End If


    End Sub

End Module

Check next sample.