Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.37314.3 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Replace_New_Line_as_LineBreak", "Replace_New_Line_as_LineBreak\Replace_New_Line_as_LineBreak.csproj", "{EC349BC0-6493-5BBA-F4AF-16FD39A32A50}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EC349BC0-6493-5BBA-F4AF-16FD39A32A50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC349BC0-6493-5BBA-F4AF-16FD39A32A50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC349BC0-6493-5BBA-F4AF-16FD39A32A50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC349BC0-6493-5BBA-F4AF-16FD39A32A50}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {336109EE-9654-4B71-A238-B38EB152721D}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;

namespace Replace_New_Line_as_LineBreak
{
class Program
{
static void Main(string[] args)
{
//Creates a new Word document.
using (WordDocument document = new WordDocument())
{
//This method adds a section and a paragraph in the document.
document.EnsureMinimal();
//Accessing the last paragraph.
IWParagraph paragraph = document.LastParagraph;
//Applying bullet style to the paragraph.
paragraph.ListFormat.ApplyDefBulletStyle();
//Text to be added.
string completeText = "Adventure Works Cycles:\nAdventure Works Cycles, the fictitious company on which the Adventure Works sample databases are based, is a large, multinational manufacturing company.\n" +
"The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets.";
//Splitting the text based on new line character.
string[] textArray = completeText.Split('\n');
//Adding the splitted text in the paragraph by inserting the LineBreak instead of new line character.
foreach (string text in textArray)
{
paragraph.AppendText(text);
paragraph.AppendBreak(BreakType.LineBreak);
}
//Saving the document.
using (FileStream outputStream = new FileStream(@"../../../Output/Result.docx", FileMode.OpenOrCreate))
{
document.Save(outputStream, FormatType.Docx);
}
}
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Replace_New_Line_as_LineBreak</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Loading