Click or drag to resize

DocumentBuilderInsertSpecialCharacter Method

Inserts a special character into the document.

Namespace: SautinSoft.Document
Assembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.7.18
Syntax
public SpecialCharacter InsertSpecialCharacter(
	SpecialCharacterType specialCharacterType
)

Parameters

specialCharacterType  SpecialCharacterType
Specifies the type of the special character to insert.

Return Value

SpecialCharacter
SpecialCharacter that was just inserted.
Example

See Developer Guide: How to insert special character using DocumentBuilder

How to insert special character using DocumentBuilder in C#
using System;
using SautinSoft.Document;
using System.Text;


namespace Example
{
    class Program
    {
        static void Main(string[] args)
        {
            // Get your free 100-day key here:   
            // https://sautinsoft.com/start-for-free/
            InsertingBreak();
        }
        /// <summary>
        /// Insert a Line Break, Column Break, Page Break using DocumentBuilder.
        /// </summary>
        /// <remarks>
        /// Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/documentbuilder-inserting-break.php
        /// </remarks>

        static void InsertingBreak()
        {
            DocumentCore dc = new DocumentCore();
            DocumentBuilder db = new DocumentBuilder(dc);

            string resultPath = @"Result.docx";
            db.PageSetup.TextColumns = new TextColumnCollection(2);

            // Insert the formatted text into the document using DocumentBuilder.
            db.CharacterFormat.FontName = "Verdana";
            db.CharacterFormat.Size = 16.5f;
            db.CharacterFormat.AllCaps = true;
            db.CharacterFormat.Italic = true;
            db.CharacterFormat.FontColor = Color.Orange;
            db.ParagraphFormat.LeftIndentation = 30;
            db.Writeln("This paragraph has a Left Indentation of 30 points.");

            db.InsertSpecialCharacter(SpecialCharacterType.LineBreak);

            // Undo the previously applied formatting.
            db.ParagraphFormat.ClearFormatting();
            db.CharacterFormat.ClearFormatting();

            db.Writeln("After this paragraph insert a column break.");
            db.InsertSpecialCharacter(SpecialCharacterType.ColumnBreak);

            db.CharacterFormat.Italic = true;
            db.CharacterFormat.FontColor = Color.DarkBlue;
            db.CharacterFormat.Size = 20f;
            db.Writeln("After this paragraph insert a page break.");
            db.InsertSpecialCharacter(SpecialCharacterType.PageBreak);

            // Save the document to the file in DOCX format.
            dc.Save(resultPath);

            // Important for Linux: Install MS Fonts
            // sudo apt install ttf-mscorefonts-installer -y

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(resultPath) { UseShellExecute = true });
        }
    }
}
How to insert special character using DocumentBuilder in VB.Net
Imports System
Imports SautinSoft.Document
Imports System.Text


Namespace Example
    Friend Class Program
        Shared Sub Main(ByVal args() As String)
            InsertingBreak()
        End Sub
                ''' Get your free 100-day key here:   
                ''' https://sautinsoft.com/start-for-free/
        ''' <summary>
        ''' Insert a Line Break, Column Break, Page Break using DocumentBuilder.
        ''' </summary>
        ''' <remarks>
        ''' Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/documentbuilder-inserting-break.php
        ''' </remarks>

        Private Shared Sub InsertingBreak()
            Dim dc As New DocumentCore()
            Dim db As New DocumentBuilder(dc)

            Dim resultPath As String = "result.docx"
            db.PageSetup.TextColumns = New TextColumnCollection(2)

            ' Insert the formatted text into the document using DocumentBuilder.
            db.CharacterFormat.FontName = "Verdana"
            db.CharacterFormat.Size = 16.5F
            db.CharacterFormat.AllCaps = True
            db.CharacterFormat.Italic = True
            db.CharacterFormat.FontColor = Color.Orange
            db.ParagraphFormat.LeftIndentation = 30
            db.Writeln("This paragraph has a Left Indentation of 30 points.")

            db.InsertSpecialCharacter(SpecialCharacterType.LineBreak)

            ' Undo the previously applied formatting.
            db.ParagraphFormat.ClearFormatting()
            db.CharacterFormat.ClearFormatting()

            db.Writeln("After this paragraph insert a column break.")
            db.InsertSpecialCharacter(SpecialCharacterType.ColumnBreak)

            db.CharacterFormat.Italic = True
            db.CharacterFormat.FontColor = Color.DarkBlue
            db.CharacterFormat.Size = 20.0F
            db.Writeln("After this paragraph insert a page break.")
            db.InsertSpecialCharacter(SpecialCharacterType.PageBreak)

            ' Save the document to the file in DOCX format.
            dc.Save(resultPath)

            ' Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(resultPath) With {.UseShellExecute = True})
        End Sub
    End Class
End Namespace
See Also