Represents a Microsoft Word document.
For a list of all members of this type, see Document Members.
System.Object
Aspose.Editor.Client.Document
[Visual Basic]
NotInheritable Public Class Document
[C#]public sealed class Document
Remarks
To load an existing document, pass a file name or a stream into one of the Document constructors. To create a blank document, call the constructor without parameters.
Use one of the Save method overloads to save the document into a file or stream.
After a document is loaded, you can open the document for editing inside an EditorControl by setting the Document property of the EditorControl object.
A Document can be opened, saved and programmatically modified without being made visible to the user in the editor control. The Document class provides methods and properties to programmatically manipulate content of the document via the Range object in a manner, similar to Microsoft Word Automation. Use GetRange methods to obtain Range objects.
All editing and formatting operations you perform on a Document are logged into the undo list and can be undone using the Undo method and redone using the Redo method.
Aspose.Editor supports documents in the following formats:
- Microsoft Office Open XML (DOCX)
- DOC - Microsoft Office Word 97 - 2007 Document
- WordprocessingML - Microsoft Office Word 2003 XML
- HTML/XHTML - XHTML 1.0 Transitional
- RTF - Rich Text Format
- Plain Text (TXT)
Example
Opens, modifies and saves a WordprocessingML document into a file.
[C#]
Document doc = new Document(MyPath + "Welcome.xml");
// Just test the modified property.
Assert.AreEqual(false, doc.IsModified);
// Let's make all text in the document italic for fun.
doc.GetRange().Italic = true;
Assert.AreEqual(true, doc.IsModified);
doc.Save(MyPath + "ExDocument.OpenSaveFile Out.xml");
[Visual Basic]
Dim doc As New Document(MyPath & "Welcome.xml")
' Just test the modified property.
Assert.AreEqual(False, doc.IsModified)
' Let's make all text in the document italic for fun.
doc.GetRange().Italic = True
Assert.AreEqual(True, doc.IsModified)
doc.Save(MyPath & "ExDocument.OpenSaveFile Out.xml")
Creates a simple Hello World document.
[C#]
Document doc = new Document();
Range range = doc.GetRange();
range.Text = "Hello World!";
range.Font.Name = "Arial";
range.Font.Size = 48;
range.Font.Italic = true;
range.Font.Color = Color.Red;
range.ParagraphFormat.SpaceBefore = 24;
range.ParagraphFormat.Alignment = ParagraphAlignment.Center;
range.ParagraphFormat.SpaceAfter = 24;
doc.Save(MyPath + "ExRange.HelloWorld Out.xml");
[Visual Basic]
Dim doc As New Document()
Dim range As Range = doc.GetRange()
range.Text = "Hello World!"
range.Font.Name = "Arial"
range.Font.Size = 48
range.Font.Italic = True
range.Font.Color = Color.Red
range.ParagraphFormat.SpaceBefore = 24
range.ParagraphFormat.Alignment = ParagraphAlignment.Center
range.ParagraphFormat.SpaceAfter = 24
doc.Save(MyPath & "ExRange.HelloWorld Out.xml")
Requirements
Namespace: Aspose.Editor.Client
Assembly: Aspose.Editor.Client (in Aspose.Editor.Client.dll)
See Also
Document Members | Aspose.Editor.Client Namespace | EditorControl | Range