Content |
The ContentRange type exposes the following members.
Name | Description | |
---|---|---|
ContentRange | Initializes a new instance of the ContentRange class. |
Name | Description | |
---|---|---|
End | Gets the ContentPosition that marks the end of the current ContentRange. | |
FormFieldsData | Gets collection of FormFieldData instances from all form fields in the current range. | |
Start | Gets the ContentPosition that marks the beginning of the current ContentRange. |
Name | Description | |
---|---|---|
Delete | Deletes the document content specified with the current ContentRange. | |
Equals |
Determines whether the specified object is equal to this ContentRange instance.
(Overrides ObjectEquals(Object)) | |
Find(Regex) | Finds all ContentRanges which match the specified Regex. | |
Find(String) | Finds all ContentRanges which contain the specified text. | |
GetHashCode |
Serves as the default hash function.
(Overrides ObjectGetHashCode) | |
Replace(ContentRange) | Replaces the content of the current ContentRange's with a content specified with the range parameter. | |
Replace(String) | Replaces the current ContentRange's content with the specified text. | |
Replace(ContentRange, ImportSession) | Replaces the content of the current ContentRange's with a content (from another DocumentCore instance) specified with the range parameter. | |
Replace(String, CharacterFormat) | Replaces the current ContentRange's content with the specified text with specific formatting. | |
Replace(String, HtmlLoadOptions) | Replaces the current ContentRange's content with the specified HTML text. | |
Replace(String, RtfLoadOptions) | Replaces the current ContentRange's content with the specified RTF text. | |
Replace(String, TxtLoadOptions) | Replaces the current ContentRange's content with the specified text. | |
Replace(String, CharacterFormat, TxtLoadOptions) | Replaces the current ContentRange's content with the specified text with specific formatting. | |
ToString |
Returns a plain text that represents this
ContentRange instance.
(Overrides ObjectToString) |
See Developer Guide: Adds two paragraphs by different ways: using ContentRange and as Element
using SautinSoft.Document; using SautinSoft.Document.Drawing; using SautinSoft.Document.Tables; using System.Linq; namespace Example { class Program { static void Main(string[] args) { // Get your free 100-day key here: // https://sautinsoft.com/start-for-free/ ContentRangeManipulation(); } /// <summary> /// Adds two paragraphs by different ways: using ContentRange and as Element. /// </summary> /// <remarks> /// Details: https://sautinsoft.com/products/document/help/net/developer-guide/contentrange-manipulation.php /// </remarks> static void ContentRangeManipulation() { string filePath = @"Result.docx"; // Let's create a new document. DocumentCore dc = new DocumentCore(); // Way 1: Add new paragraph using the property Content (class ContentRange). Paragraph par = new Paragraph(dc, "This is paragraph. "); par.ParagraphFormat.BackgroundColor = Color.Yellow; // Note, our Paragraph will be cloned and the clone will be inserted. // The property Content (class ContentRange) each time clones the inserting object. dc.Content.End.Insert(par.Content); // Way 2: Add paragraph into the Block collection as Element. // Note, you can't insert the one Element two times. // The cloning does not occur here. par.ParagraphFormat.BackgroundColor = Color.Red; dc.Sections[0].Blocks.Add(par); // Again Way 1: Change Background color to blue and insert // the copy (clone) of our paragraph using Content (class ContentRange). par.ParagraphFormat.BackgroundColor = Color.Blue; dc.Content.End.Insert(par.Content); // Change background to 'Green' for the paragraph. // This affect only to the paragraph inserted by 'Way 2' - as Element. // Because in 'Way 1' we added clones using ContentRange. par.ParagraphFormat.BackgroundColor = Color.Green; // Save our document. dc.Save(filePath); // Open the result for demonstration purposes. System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true }); } } }
Imports SautinSoft.Document Imports SautinSoft.Document.Drawing Imports SautinSoft.Document.Tables Imports System.Linq Module Sample Sub Main() ContentRangeManipulation() End Sub ''' Get your free 100-day key here: ''' https://sautinsoft.com/start-for-free/ ''' <summary> ''' Adds two paragraphs by different ways: using ContentRange and as Element. ''' </summary> ''' <remarks> ''' Details: https://sautinsoft.com/products/document/help/net/developer-guide/contentrange-manipulation.php ''' </remarks> Sub ContentRangeManipulation() Dim filePath As String = "Result.docx" ' Let's create a new document. Dim dc As New DocumentCore() ' Way 1: Add new paragraph using the property Content (class ContentRange). Dim par As New Paragraph(dc, "This is paragraph. ") par.ParagraphFormat.BackgroundColor = Color.Yellow ' Note, our Paragraph will be cloned and the clone will be inserted. ' The property Content (class ContentRange) each time clones the inserting object. dc.Content.End.Insert(par.Content) ' Way 2: Add paragraph into the Block collection as Element. ' Note, you can't insert the one Element two times. ' The cloning does not occur here. par.ParagraphFormat.BackgroundColor = Color.Red dc.Sections(0).Blocks.Add(par) ' Again Way 1: Change Background color to blue and insert ' the copy (clone) of our paragraph using Content (class ContentRange). par.ParagraphFormat.BackgroundColor = Color.Blue dc.Content.End.Insert(par.Content) ' Change background to 'Green' for the paragraph. ' This affect only to the paragraph inserted by 'Way 2' - as Element. ' Because in 'Way 1' we added clones using ContentRange. par.ParagraphFormat.BackgroundColor = Color.Green ' Save our document. 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