Skip to content

Commit a265b52

Browse files
Merge pull request #301 from Suriya-Balamurugan/main
Added README files for DocIO interactive sample browser
2 parents 2c5cc2b + 2099cb0 commit a265b52

File tree

24 files changed

+1362
-2
lines changed
  • Bookmarks/Replace-content-with-body-part/.NET/Replace-content-with-body-part
  • Compare-Word-documents/Compare-two-Word-documents/.NET/Compare-Word-documents
  • Content-Controls/Fill-form-in-Word-document/.NET/Fill-form-in-Word-document
  • Find-and-Replace/Replace-misspelled-word/.NET/Replace-misspelled-word
  • HTML-conversions
    • Convert-HTML-to-Word/.NET/Convert-HTML-to-Word
    • Convert-Word-to-HTML/.NET/Convert-Word-to-HTML
  • Mail-Merge/Mail-merge-with-implicit-relational-data/.NET/Mail-merge-with-implicit-relational-data
  • Markdown-to-Word-conversion/Convert-Markdown-to-Word/.NET/Convert-Markdown-to-Word
  • Security
    • Encrypt-Word-document-with-password/.NET/Encrypt-Word-document-with-password
    • Remove-encryption-from-Word-document/.NET/Remove-encryption-from-Word-document
  • Table-Of-Contents/Add-table-of-contents/.NET/Add-table-of-contents
  • Tables/Apply-table-formatting/.NET/Apply-table-formatting
  • Text-file-conversion/Convert-Word-to-text-file/.NET/Convert-Word-to-text-file
  • Word-document
    • Merge-documents-in-new-page/.NET/Merge-documents-in-new-page
    • Split-by-bookmark/.NET/Split-by-bookmark
    • Split-by-heading/.NET/Split-by-heading
    • Split-by-placeholder-text/.NET/Split-by-placeholder-text
    • Split-by-section/.NET/Split-by-section
  • Word-to-Image-conversion/First-page-of-Word-to-image/.NET/First-page-of-Word-to-image
  • Word-to-Markdown-conversion/Convert-Word-to-Markdown/.NET/Convert-Word-to-Markdown
  • Word-to-PDF-Conversion
    • Convert-Word-document-to-PDF/.NET/Convert-Word-document-to-PDF
    • Convert-Word-into-accessible-PDF/.NET/Convert-Word-into-accessible-PDF
    • PDF-conformance-level/.NET/PDF-conformance-level

24 files changed

+1362
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Replace bookmark content in a Word document using C#
2+
3+
The Syncfusion [.NET Word Library](https://www.syncfusion.com/document-processing/word-framework/net/word-library) (DocIO) enables you to create, read, and edit Word documents programmatically without Microsoft Word or interop dependencies. Using this library, you can **replace bookmark content in a Word document** using C#.
4+
5+
## Steps to replace bookmark content programmatically
6+
7+
Step 1: Create a new .NET Core console application project.
8+
9+
Step 2: Install the [Syncfusion.DocIO.Net.Core](https://www.nuget.org/packages/Syncfusion.DocIO.Net.Core) NuGet package as a reference to your project from [NuGet.org](https://www.nuget.org/).
10+
11+
Step 3: Include the following namespaces in the Program.cs file.
12+
13+
```csharp
14+
using Syncfusion.DocIO;
15+
using Syncfusion.DocIO.DLS;
16+
using System.IO;
17+
```
18+
19+
Step 4: Add the following code snippet in Program.cs file to replace bookmark content in the Word document.
20+
21+
```csharp
22+
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
23+
{
24+
//Opens an existing Word document.
25+
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Automatic))
26+
{
27+
//Creates the bookmark navigator instance to access the bookmark.
28+
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
29+
//Moves the virtual cursor to the location before the end of the bookmark "Northwind".
30+
bookmarkNavigator.MoveToBookmark("Northwind");
31+
//Gets the bookmark content.
32+
TextBodyPart textBodyPart = bookmarkNavigator.GetBookmarkContent();
33+
document.AddSection();
34+
IWParagraph paragraph = document.LastSection.AddParagraph();
35+
paragraph.AppendText("Northwind Database is a set of tables containing data fitted into predefined categories.");
36+
//Adds the new bookmark into Word document.
37+
paragraph.AppendBookmarkStart("bookmark_empty");
38+
paragraph.AppendBookmarkEnd("bookmark_empty");
39+
//Moves the virtual cursor to the location before the end of the bookmark "bookmark_empty".
40+
bookmarkNavigator.MoveToBookmark("bookmark_empty");
41+
//Replaces the bookmark content with text body part.
42+
bookmarkNavigator.ReplaceBookmarkContent(textBodyPart);
43+
//Creates file stream.
44+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite))
45+
{
46+
//Saves the Word document to file stream.
47+
document.Save(outputFileStream, FormatType.Docx);
48+
}
49+
}
50+
}
51+
```
52+
53+
More information about the bookmarks can be found in this [documentation](https://help.syncfusion.com/document-processing/word/word-library/net/working-with-bookmarks) section.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Compare Word documents using C#
2+
3+
The Syncfusion [.NET Word Library](https://www.syncfusion.com/document-processing/word-framework/net/word-library) (DocIO) enables you to create, read, and edit Word documents programmatically without Microsoft Word or interop dependencies. Using this library, you can **compare Word documents** using C#.
4+
5+
## Steps to compare Word documents programmatically
6+
7+
Step 1: Create a new .NET Core console application project.
8+
9+
Step 2: Install the [Syncfusion.DocIO.Net.Core](https://www.nuget.org/packages/Syncfusion.DocIO.Net.Core) NuGet package as a reference to your project from [NuGet.org](https://www.nuget.org/).
10+
11+
Step 3: Include the following namespaces in the Program.cs file.
12+
13+
```csharp
14+
using Syncfusion.DocIO;
15+
using Syncfusion.DocIO.DLS;
16+
using System.IO;
17+
```
18+
19+
Step 4: Add the following code snippet in Program.cs file to compare Word documents.
20+
21+
```csharp
22+
//Loads the original document.
23+
using (FileStream originalDocumentStreamPath = new FileStream(Path.GetFullPath(@"Data/OriginalDocument.docx"), FileMode.Open, FileAccess.Read))
24+
{
25+
using (WordDocument originalDocument = new WordDocument(originalDocumentStreamPath, FormatType.Docx))
26+
{
27+
//Loads the revised document
28+
using (FileStream revisedDocumentStreamPath = new FileStream(Path.GetFullPath(@"Data/RevisedDocument.docx"), FileMode.Open, FileAccess.Read))
29+
{
30+
using (WordDocument revisedDocument = new WordDocument(revisedDocumentStreamPath, FormatType.Docx))
31+
{
32+
//Compare the original and revised Word documents.
33+
originalDocument.Compare(revisedDocument);
34+
//Save the Word document.
35+
using (FileStream fileStreamOutput = File.Create(Path.GetFullPath("Output/Output.docx")))
36+
{
37+
originalDocument.Save(fileStreamOutput, FormatType.Docx);
38+
}
39+
}
40+
}
41+
}
42+
}
43+
```
44+
45+
More information about comparing Word document can be found in this [documentation](https://help.syncfusion.com/document-processing/word/word-library/net/word-document/compare-word-documents) section.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Form filling in Word document using C#
2+
3+
The Syncfusion [.NET Word Library](https://www.syncfusion.com/document-processing/word-framework/net/word-library) (DocIO) enables you to create, read, and edit Word documents programmatically without Microsoft Word or interop dependencies. Using this library, you can **fill forms in a Word document** using C#.
4+
5+
## Steps to fill forms programmatically
6+
7+
Step 1: Create a new .NET Core console application project.
8+
9+
Step 2: Install the [Syncfusion.DocIO.Net.Core](https://www.nuget.org/packages/Syncfusion.DocIO.Net.Core) NuGet package as a reference to your project from [NuGet.org](https://www.nuget.org/).
10+
11+
Step 3: Include the following namespaces in the Program.cs file.
12+
13+
```csharp
14+
using Syncfusion.DocIO;
15+
using Syncfusion.DocIO.DLS;
16+
using System.IO;
17+
```
18+
19+
Step 4: Add the following code snippet in Program.cs file to fill forms in the Word document.
20+
21+
```csharp
22+
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
23+
{
24+
//Creates a new Word document.
25+
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Automatic))
26+
{
27+
IWSection sec = document.LastSection;
28+
InlineContentControl inlineCC;
29+
InlineContentControl dropDownCC;
30+
WTable table1 = sec.Tables[1] as WTable;
31+
WTableRow row1 = table1.Rows[1];
32+
33+
#region General Information
34+
//Fill the name.
35+
WParagraph cellPara1 = row1.Cells[0].ChildEntities[1] as WParagraph;
36+
inlineCC = cellPara1.ChildEntities.LastItem as InlineContentControl;
37+
WTextRange text = new WTextRange(document);
38+
text.ApplyCharacterFormat(inlineCC.BreakCharacterFormat);
39+
text.Text = "Steve Jobs";
40+
inlineCC.ParagraphItems.Add(text);
41+
//Fill the date of birth.
42+
cellPara1 = row1.Cells[0].ChildEntities[3] as WParagraph;
43+
inlineCC = cellPara1.ChildEntities.LastItem as InlineContentControl;
44+
text = new WTextRange(document);
45+
text.ApplyCharacterFormat(inlineCC.BreakCharacterFormat);
46+
text.Text = "06/01/1994";
47+
inlineCC.ParagraphItems.Add(text);
48+
//Fill the address.
49+
cellPara1 = row1.Cells[0].ChildEntities[5] as WParagraph;
50+
inlineCC = cellPara1.ChildEntities.LastItem as InlineContentControl;
51+
text = new WTextRange(document);
52+
text.ApplyCharacterFormat(inlineCC.BreakCharacterFormat);
53+
text.Text = "2501 Aerial Center Parkway.";
54+
inlineCC.ParagraphItems.Add(text);
55+
text = new WTextRange(document);
56+
text.ApplyCharacterFormat(inlineCC.BreakCharacterFormat);
57+
text.Text = "Morrisville, NC 27560.";
58+
inlineCC.ParagraphItems.Add(text);
59+
text = new WTextRange(document);
60+
text.ApplyCharacterFormat(inlineCC.BreakCharacterFormat);
61+
text.Text = "USA.";
62+
inlineCC.ParagraphItems.Add(text);
63+
//Fill the phone no.
64+
cellPara1 = row1.Cells[0].ChildEntities[7] as WParagraph;
65+
inlineCC = cellPara1.ChildEntities.LastItem as InlineContentControl;
66+
text = new WTextRange(document);
67+
text.ApplyCharacterFormat(inlineCC.BreakCharacterFormat);
68+
text.Text = "+1 919.481.1974";
69+
inlineCC.ParagraphItems.Add(text);
70+
//Fill the email id.
71+
cellPara1 = row1.Cells[0].ChildEntities[9] as WParagraph;
72+
inlineCC = cellPara1.ChildEntities.LastItem as InlineContentControl;
73+
text = new WTextRange(document);
74+
text.ApplyCharacterFormat(inlineCC.BreakCharacterFormat);
75+
text.Text = "[email protected]";
76+
inlineCC.ParagraphItems.Add(text);
77+
#endregion
78+
79+
#region Educational Information
80+
table1 = sec.Tables[2] as WTable;
81+
row1 = table1.Rows[1];
82+
//Fill the education type.
83+
cellPara1 = row1.Cells[0].ChildEntities[1] as WParagraph;
84+
dropDownCC = cellPara1.ChildEntities.LastItem as InlineContentControl;
85+
text = new WTextRange(document);
86+
text.ApplyCharacterFormat(dropDownCC.BreakCharacterFormat);
87+
text.Text = dropDownCC.ContentControlProperties.ContentControlListItems[1].DisplayText;
88+
dropDownCC.ParagraphItems.Add(text);
89+
//Fill the university.
90+
cellPara1 = row1.Cells[0].ChildEntities[3] as WParagraph;
91+
inlineCC = cellPara1.ChildEntities.LastItem as InlineContentControl;
92+
text = new WTextRange(document);
93+
text.ApplyCharacterFormat(dropDownCC.BreakCharacterFormat);
94+
text.Text = "Michigan University";
95+
inlineCC.ParagraphItems.Add(text);
96+
//Fill the C# experience level.
97+
cellPara1 = row1.Cells[0].ChildEntities[7] as WParagraph;
98+
dropDownCC = cellPara1.ChildEntities.LastItem as InlineContentControl;
99+
text = new WTextRange(document);
100+
text.ApplyCharacterFormat(dropDownCC.BreakCharacterFormat);
101+
text.Text = dropDownCC.ContentControlProperties.ContentControlListItems[2].DisplayText;
102+
dropDownCC.ParagraphItems.Add(text);
103+
//Fill the VB experience level.
104+
cellPara1 = row1.Cells[0].ChildEntities[9] as WParagraph;
105+
dropDownCC = cellPara1.ChildEntities.LastItem as InlineContentControl;
106+
text = new WTextRange(document);
107+
text.ApplyCharacterFormat(dropDownCC.BreakCharacterFormat);
108+
text.Text = dropDownCC.ContentControlProperties.ContentControlListItems[1].DisplayText;
109+
dropDownCC.ParagraphItems.Add(text);
110+
#endregion
111+
//Creates file stream.
112+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite))
113+
{
114+
//Saves the Word document to file stream.
115+
document.Save(outputFileStream, FormatType.Docx);
116+
}
117+
}
118+
}
119+
```
120+
121+
More information about the content controls can be found in this [documentation](https://help.syncfusion.com/document-processing/word/word-library/net/working-with-content-controls) section.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Find and replace text in Word document using C#
2+
3+
The Syncfusion [.NET Word Library](https://www.syncfusion.com/document-processing/word-framework/net/word-library) (DocIO) enables you to create, read, and edit Word documents programmatically without Microsoft Word or interop dependencies. Using this library, you can **find and replace text in a Word document** using C#.
4+
5+
## Steps to find and replace text programmatically
6+
7+
Step 1: Create a new .NET Core console application project.
8+
9+
Step 2: Install the [Syncfusion.DocIO.Net.Core](https://www.nuget.org/packages/Syncfusion.DocIO.Net.Core) NuGet package as a reference to your project from [NuGet.org](https://www.nuget.org/).
10+
11+
Step 3: Include the following namespaces in the Program.cs file.
12+
13+
```csharp
14+
using Syncfusion.DocIO;
15+
using Syncfusion.DocIO.DLS;
16+
using System.IO;
17+
```
18+
19+
Step 4: Add the following code snippet in Program.cs file to find and replace text in the Word document.
20+
21+
```csharp
22+
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
23+
{
24+
//Opens an existing Word document.
25+
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx))
26+
{
27+
//Finds all occurrences of a misspelled word and replaces with properly spelled word.
28+
document.Replace("Cyles", "Cycles", true, true);
29+
//Creates file stream.
30+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
31+
{
32+
//Saves the Word document to file stream.
33+
document.Save(outputFileStream, FormatType.Docx);
34+
}
35+
}
36+
}
37+
```
38+
39+
More information about find and replace functionality can be found in this [documentation](https://help.syncfusion.com/document-processing/word/word-library/net/working-with-find-and-replace) section.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Convert HTML to Word document using C#
2+
3+
The Syncfusion [.NET Word Library](https://www.syncfusion.com/document-processing/word-framework/net/word-library) (DocIO) enables you to create, read, edit, and convert Word documents programmatically without Microsoft Word or interop dependencies. Using this library, you can **convert HTML to a Word document** using C#.
4+
5+
## Steps to convert HTML to Word programmatically
6+
7+
Step 1: Create a new .NET Core console application project.
8+
9+
Step 2: Install the [Syncfusion.DocIO.Net.Core](https://www.nuget.org/packages/Syncfusion.DocIO.Net.Core) NuGet package as a reference to your project from [NuGet.org](https://www.nuget.org/).
10+
11+
Step 3: Include the following namespaces in the Program.cs file.
12+
13+
```csharp
14+
using Syncfusion.DocIO;
15+
using Syncfusion.DocIO.DLS;
16+
using System.IO;
17+
```
18+
19+
Step 4: Add the following code snippet in Program.cs file to convert HTML to a Word document.
20+
21+
```csharp
22+
//Loads an existing Word document into DocIO instance.
23+
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
24+
{
25+
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx))
26+
{
27+
//Creates file stream.
28+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/WordToHtml.html"), FileMode.Create, FileAccess.ReadWrite))
29+
{
30+
//Saves the Word document to file stream.
31+
document.Save(outputFileStream, FormatType.Html);
32+
}
33+
}
34+
}
35+
```
36+
37+
More information about HTML to Word conversion and vice versa can be found in this [documentation](https://help.syncfusion.com/document-processing/word/word-library/net/html) section.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Convert Word document to HTML using C#
2+
3+
The Syncfusion [.NET Word Library](https://www.syncfusion.com/document-processing/word-framework/net/word-library) (DocIO) enables you to create, read, edit, and convert Word documents programmatically without Microsoft Word or interop dependencies. Using this library, you can **convert a Word document to HTML** using C#.
4+
5+
## Steps to convert Word to HTML programmatically
6+
7+
Step 1: Create a new .NET Core console application project.
8+
9+
Step 2: Install the [Syncfusion.DocIO.Net.Core](https://www.nuget.org/packages/Syncfusion.DocIO.Net.Core) NuGet package as a reference to your project from [NuGet.org](https://www.nuget.org/).
10+
11+
Step 3: Include the following namespaces in the Program.cs file.
12+
13+
```csharp
14+
using Syncfusion.DocIO;
15+
using Syncfusion.DocIO.DLS;
16+
using System.IO;
17+
```
18+
19+
Step 4: Add the following code snippet in Program.cs file to convert a Word document to HTML.
20+
21+
```csharp
22+
//Loads an existing Word document into DocIO instance.
23+
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
24+
{
25+
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx))
26+
{
27+
//Creates file stream.
28+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/WordToHtml.html"), FileMode.Create, FileAccess.ReadWrite))
29+
{
30+
//Saves the Word document to file stream.
31+
document.Save(outputFileStream, FormatType.Html);
32+
}
33+
}
34+
}
35+
```
36+
37+
More information about Word to HTML conversion and vice versa can be found in this [documentation](https://help.syncfusion.com/document-processing/word/word-library/net/html) section.

0 commit comments

Comments
 (0)