Delete Content

Following example shows how to delete part of document content with GemBox.Document component.

Delete Content Screenshot
Upload your file (Drag file here)
using System.Linq;
using GemBox.Document;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        DocumentModel document = DocumentModel.Load("%InputFileName%");

        // Delete paragraph break between 1st and 2nd paragraph (concatenate 1st and 2nd paragraph)
        var blocks = document.Sections[0].Blocks;
        var paragraphBreakRange = new ContentRange(blocks[0].Content.End, blocks[1].Content.Start);
        paragraphBreakRange.Delete();

        // Delete content of 2nd run
        blocks.Cast<Paragraph>(0).Inlines[1].Content.Delete();

        document.Save("Delete Content.%OutputFileType%");
    }
}
Imports System.Linq
Imports GemBox.Document

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim document As DocumentModel = DocumentModel.Load("%InputFileName%")

        ' Delete paragraph break between 1st and 2nd paragraph (concatenate 1st and 2nd paragraph)
        Dim blocks = document.Sections(0).Blocks
        Dim paragraphBreakRange = New ContentRange(blocks(0).Content.End, blocks(1).Content.Start)
        paragraphBreakRange.Delete()

        ' Delete content of 2nd run
        blocks.Cast(Of Paragraph)(0).Inlines(1).Content.Delete()

        document.Save("Delete Content.%OutputFileType%")

    End Sub

End Module

Check next example or download examples from GitHub.