Click or drag to resize

DocumentCore Class

The main class of "Document .Net" library. Represets a document itself.
Inheritance Hierarchy

Namespace:  SautinSoft.Document
Assembly:  SautinSoft.Document (in SautinSoft.Document.dll) Version: 3.8.6.14 (3.8.6.14)
Syntax
public sealed class DocumentCore : Element, 
	IContentElement

The DocumentCore type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleDocumentCore
Initializes a new instance of the DocumentCore class.
Top
Properties
  NameDescription
Public propertyCode exampleBookmarks
Gets the document bookmarks.
Public propertyContent
Gets the ContentRange of the current element.
(Inherited from Element.)
Public propertyCode exampleDefaultCharacterFormat
Gets or sets the default character format.
Public propertyCode exampleDefaultParagraphFormat
Gets or sets the default paragraph format.
Public propertyDocument
Gets the owner document.
(Inherited from Element.)
Public propertyEditProtection
Gets or sets the document protection settings used to restrict editing and formatting of document content. Supported in DOCX format.
Public propertyElementType
Gets the ElementType of this element instance.
(Overrides ElementElementType.)
Public propertyCode exampleMailMerge
Gets a MailMerge object that represents the mail merge functionality for the document.
Public propertyNextSibling
Gets the next Element sibling.
(Inherited from Element.)
Public propertyParent
Gets the parent of this element instance.
(Inherited from Element.)
Public propertyParentCollection
Gets the ElementCollection that contains this element instance.
(Inherited from Element.)
Public propertyPreviuosSibling
Gets the previous Element sibling.
(Inherited from Element.)
Public propertyCode exampleProperties
Gets the document properties.
Public propertyCode exampleSections
Gets a collection that represents all sections in the document.
Public propertyStatic memberCode exampleSerial
Allows to activate your copy of the component after purchasing.
Public propertySettings
Gets or sets the document settings.
Public propertyCode exampleStyles
Gets a collection of styles defined in the document.
Public propertyWriteProtection
Gets the document write protection options. Supported only in DOCX format.
Top
Methods
  NameDescription
Public methodCalculateListItems
Calculates the list items contained in this document.
Public methodCode exampleCalculateStats
Calculates document's statistics (number of words, number of pages and etc).
Public methodClone
Clones this DocumentCore instance.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodCode exampleGetChildElements(Boolean)
Gets the child elements.
(Inherited from Element.)
Public methodCode exampleGetChildElements(Boolean, ElementType)
Gets the child elements filtered by ElementType.
(Inherited from Element.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodCode exampleGetPaginator
Gets the document paginator.
Public methodCode exampleGetPaginator(PaginatorOptions)
Gets the document paginator.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodCode exampleImportT(T, Boolean)
Imports (clones) the specified source element to this DocumentCore instance so it can be inserted into document content.
Public methodCode exampleImportT(T, Boolean, ImportSession)
Imports (clones) the specified source element to this DocumentCore instance so it can be inserted into document content.
Public methodStatic memberCode exampleLoad(String)
Loads a document from a file with the specified path.
Public methodStatic memberCode exampleLoad(Stream, LoadOptions)
Loads a document from the specified stream.
Public methodStatic memberCode exampleLoad(String, LoadOptions)
Loads a document from a file with the specified path.
Public methodCode exampleSave(String)
Saves the document to a file with the specified path. Path must include file extension.
Public methodCode exampleSave(Stream, SaveOptions)
Saves the document in the specified stream.
Public methodCode exampleSave(String, SaveOptions)
Saves the document to a file with the specified path.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Explicit Interface Implementations
Examples
How to create a new document and saves it in a desired format in C#
using SautinSoft.Document;

namespace Example
{
    class Program
    {        
        static void Main(string[] args)
        {
            CreateDocument();
        }

        /// <summary>
        /// Creates a new document and saves it in a desired format.
        /// </summary>
        /// <remarks>
        /// Details: https://www.sautinsoft.com/products/document/examples/create-document.php
        /// </remarks>
        static void CreateDocument()
        {            
            DocumentCore dc = new DocumentCore();
            dc.Content.End.Insert("Hello World!", new CharacterFormat() { FontName = "Verdana", Size = 65.5f, FontColor = Color.Orange });

            // Save a document to a file in DOCX format.
            string filePath = @"Result.docx";
            dc.Save(filePath);

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true });
        }
    }
}
How to create a new document and saves it in a desired format in VB.Net
Imports SautinSoft.Document

Module Sample
    Sub Main()
        CreateDocument()
    End Sub

    ''' <summary>
    ''' Creates a new document and saves it in a desired format.
    ''' </summary>
    ''' <remarks>
    ''' Details: https://www.sautinsoft.com/products/document/examples/create-document.php
    ''' </remarks>
    Sub CreateDocument()
        Dim dc As New DocumentCore()
        dc.Content.End.Insert("Hello World!", New CharacterFormat() With {
                .FontName = "Verdana",
                .Size = 65.5F,
                .FontColor = Color.Orange
            })

        ' Save a document to a file in DOCX format.
        Dim filePath As String = "Result.docx"
        dc.Save(filePath)

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