Skip to content

Commit 5544548

Browse files
Merge pull request #576 from SyncfusionExamples/Update_ExtractText
1041234-Updated the GitHub sample for Extract Text in DocIO Examples
2 parents f706939 + c271b3f commit 5544548

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

Word-document/Extract-Text-From-Word-Document/.NET/Extract-Text-From-Word-Document/Extract-Text-From-Word-Document.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
<None Update="Data\Template.docx">
1515
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
1616
</None>
17+
<None Update="Output\.gitkeep">
18+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
19+
</None>
1720
</ItemGroup>
1821

1922
</Project>

Word-document/Extract-Text-From-Word-Document/.NET/Extract-Text-From-Word-Document/Output/.gitkeep

Whitespace-only changes.

Word-document/Extract-Text-From-Word-Document/.NET/Extract-Text-From-Word-Document/Program.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
using Syncfusion.DocIO.DLS;
55

66
// Loads a template document
7-
WordDocument document = new WordDocument(Path.GetFullPath(@"Data/Template.docx"));
8-
// Gets the document text
9-
string text = document.GetText();
10-
// Prints the extracted text to the console
11-
Console.WriteLine(text);
12-
// Dispose the document instance
13-
document.Close();
7+
using (WordDocument document = new WordDocument(Path.GetFullPath(@"Data/Template.docx")))
8+
{
9+
// Get the document text
10+
string text = document.GetText();
11+
12+
// Save the text to a file
13+
string outputPath = Path.GetFullPath(@"Output/Output.txt");
14+
File.WriteAllText(outputPath, text);
15+
}

0 commit comments

Comments
 (0)