Skip to content

Commit 1749982

Browse files
author
Konduru Keerthi Konduru Ravichandra Raju
committed
Replace text with barcode
1 parent dcbe95f commit 1749982

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.10.34928.147
5+
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}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
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
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {42395310-B4CE-44D0-98FB-97049E023E7A}
24+
EndGlobalSection
25+
EndGlobal
Binary file not shown.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Syncfusion.DocIO.DLS;
2+
using Syncfusion.DocIO;
3+
4+
namespace Replace_text_with_barcode
5+
{
6+
internal class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
//Open an existing document
11+
using (FileStream inputStream = new FileStream(@"../../../Data/Template.docx", FileMode.Open, FileAccess.Read))
12+
{
13+
using (WordDocument document = new WordDocument(inputStream, FormatType.Docx))
14+
{
15+
//Find all instances of the target word in the document
16+
TextSelection[] textSelections = document.FindAll("Barcode", false, true);
17+
18+
foreach (TextSelection selection in textSelections)
19+
{
20+
//Apply the font style
21+
selection.GetAsOneRange().CharacterFormat.FontName = "Code 128";
22+
selection.GetAsOneRange().CharacterFormat.Bold = true;
23+
selection.GetAsOneRange().CharacterFormat.Italic = true;
24+
}
25+
26+
//Save the Word document
27+
using (FileStream outputStream = new FileStream(@"../../../Output.docx", FileMode.Create, FileAccess.Write))
28+
{
29+
document.Save(outputStream, FormatType.Docx);
30+
}
31+
}
32+
}
33+
}
34+
}
35+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Replace_text_with_barcode</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
</Project>

0 commit comments

Comments
 (0)