Skip to content

Commit 00b0e79

Browse files
author
Konduru Keerthi Konduru Ravichandra Raju
committed
Replace text with barcode
1 parent 68c78b1 commit 00b0e79

File tree

5 files changed

+31
-42
lines changed

5 files changed

+31
-42
lines changed

Find-and-Replace/Replace-text-with-barcode/.NET/Replace-text-with-barcode.sln renamed to Find-and-Replace/Find-and-change-font-for-text/.NET/Find-and-change-font-for-text.sln

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.10.34928.147
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Replace-text-with-barcode", "Replace-text-with-barcode\Replace-text-with-barcode.csproj", "{6E0FE4DE-E3B7-4BBA-981B-B506FC459E6C}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Find-and-change-font-for-text", "Find-and-change-font-for-text\Find-and-change-font-for-text.csproj", "{DFE9F723-DACC-49B2-8617-03E56AB788D7}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{6E0FE4DE-E3B7-4BBA-981B-B506FC459E6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{6E0FE4DE-E3B7-4BBA-981B-B506FC459E6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{6E0FE4DE-E3B7-4BBA-981B-B506FC459E6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{6E0FE4DE-E3B7-4BBA-981B-B506FC459E6C}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{DFE9F723-DACC-49B2-8617-03E56AB788D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{DFE9F723-DACC-49B2-8617-03E56AB788D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{DFE9F723-DACC-49B2-8617-03E56AB788D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{DFE9F723-DACC-49B2-8617-03E56AB788D7}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {42395310-B4CE-44D0-98FB-97049E023E7A}
23+
SolutionGuid = {B0656087-A267-4AB1-8BC3-687BE238A563}
2424
EndGlobalSection
2525
EndGlobal

Find-and-Replace/Replace-text-with-barcode/.NET/Replace-text-with-barcode/Data/Template.docx renamed to Find-and-Replace/Find-and-change-font-for-text/.NET/Find-and-change-font-for-text/Data/Template.docx

File renamed without changes.

Find-and-Replace/Replace-text-with-barcode/.NET/Replace-text-with-barcode/Replace-text-with-barcode.csproj renamed to Find-and-Replace/Find-and-change-font-for-text/.NET/Find-and-change-font-for-text/Find-and-change-font-for-text.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net8.0</TargetFramework>
6-
<RootNamespace>Replace_text_with_barcode</RootNamespace>
6+
<RootNamespace>Find_and_change_font_for_text</RootNamespace>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<Nullable>enable</Nullable>
99
</PropertyGroup>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Syncfusion.DocIO.DLS;
2+
using Syncfusion.DocIO;
3+
4+
//Open an existing document
5+
using (FileStream inputStream = new FileStream(@"../../../Data/Template.docx", FileMode.Open, FileAccess.Read))
6+
{
7+
using (WordDocument document = new WordDocument(inputStream, FormatType.Docx))
8+
{
9+
//Find all instances of the target word in the document
10+
TextSelection[] textSelections = document.FindAll("Barcode", false, true);
11+
12+
foreach (TextSelection selection in textSelections)
13+
{
14+
//Apply the barcode font style
15+
selection.GetAsOneRange().CharacterFormat.FontName = "Code 128";
16+
}
17+
18+
//Save the Word document
19+
using (FileStream outputStream = new FileStream(@"../../../Output.docx", FileMode.Create, FileAccess.Write))
20+
{
21+
document.Save(outputStream, FormatType.Docx);
22+
}
23+
}
24+
}

Find-and-Replace/Replace-text-with-barcode/.NET/Replace-text-with-barcode/Program.cs

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)