Click or drag to resize

DocumentBuilderWrite Method

Inserts a string into the document at the current insert position.

Namespace: SautinSoft.Document
Assembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.7.18
Syntax
public void Write(
	string text
)

Parameters

text  String
The string to insert into the document.
Example

See Developer Guide: How to insert formatted text using DocumentBuilder

How to insert formatted text 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/
            InsertingText();
        }
        /// <summary>
        /// Create a document and insert a string of text using DocumentBuilder.
        /// </summary>
        /// <remarks>
        /// Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/documentbuilder-inserting-text.php
        /// </remarks>

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

            string resultPath = @"Result.pdf";

            // Insert the formatted text into the document using DocumentBuilder.
            db.CharacterFormat.FontName = "Verdana";
            db.CharacterFormat.Size = 55.5f;
            db.CharacterFormat.AllCaps = true;
            db.CharacterFormat.Italic = true;
            db.CharacterFormat.FontColor = Color.Orange;
            db.Write("insert a text using");

            db.InsertSpecialCharacter(SpecialCharacterType.LineBreak);

            db.CharacterFormat.Size = 52.5f;
            db.CharacterFormat.FontColor = Color.Blue;
            db.CharacterFormat.AllCaps = false;
            db.CharacterFormat.Italic = false;
            db.Write("DocumentBuilder");

            // Save the document to the file in PDF format.
            dc.Save(resultPath, new PdfSaveOptions()
            { Compliance = PdfCompliance.PDF_A1a });

            // 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 formatted text 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)
            InsertingText()
        End Sub
                ''' Get your free 100-day key here:   
                ''' https://sautinsoft.com/start-for-free/
        ''' <summary>
        ''' Create a document and insert a string of text using DocumentBuilder.
        ''' </summary>
        ''' <remarks>
        ''' Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/documentbuilder-inserting-text.php
        ''' </remarks>

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

            Dim resultPath As String = "result.pdf"

            ' Insert the formatted text into the document using DocumentBuilder.
            db.CharacterFormat.FontName = "Verdana"
            db.CharacterFormat.Size = 55.5F
            db.CharacterFormat.AllCaps = True
            db.CharacterFormat.Italic = True
            db.CharacterFormat.FontColor = Color.Orange
            db.Write("insert a text using")

            db.InsertSpecialCharacter(SpecialCharacterType.LineBreak)

            db.CharacterFormat.Size = 52.5F
            db.CharacterFormat.FontColor = Color.Blue
            db.CharacterFormat.AllCaps = False
            db.CharacterFormat.Italic = False
            db.Write("DocumentBuilder")

            ' Save the document to the file in PDF format.
            dc.Save(resultPath, New PdfSaveOptions() With {.Compliance = PdfCompliance.PDF_A1a})

            ' 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) With {.UseShellExecute = True})
        End Sub
    End Class
End Namespace
See Also