Skip to content

Commit

Permalink
Paragraphs
Browse files Browse the repository at this point in the history
  • Loading branch information
KonduruKeerthi committed Jul 29, 2024
1 parent 3cb49d3 commit 06b99da
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Paragraphs/Remove_all_page_breaks/.NET/Remove_all_page_breaks.sln
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.10.34928.147
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Remove_all_page_breaks", "Remove_all_page_breaks\Remove_all_page_breaks.csproj", "{BBAF7F96-C858-4CE2-AEA5-5192110B8CB8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BBAF7F96-C858-4CE2-AEA5-5192110B8CB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBAF7F96-C858-4CE2-AEA5-5192110B8CB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBAF7F96-C858-4CE2-AEA5-5192110B8CB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBAF7F96-C858-4CE2-AEA5-5192110B8CB8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5AA2BDB5-3AE9-4E8D-8115-E0B1DF21850D}
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;

using (FileStream inputStream = new FileStream(@"../../../Data/Template.docx", FileMode.Open, FileAccess.Read))
{
//Open the existing Word document.
using (WordDocument document = new WordDocument(inputStream, FormatType.Docx))
{
//Get the list of page breaks
List<Entity> entities = document.FindAllItemsByProperty(EntityType.Break, "BreakType", "PageBreak");

//Iterate through all page breaks and remove it from the owner paragraph
foreach (Entity entity in entities)
(entity as Break).OwnerParagraph.ChildEntities.Remove(entity);

//Save the Word document
using (FileStream outputStream = new FileStream(@"../../../Output.docx", FileMode.Create, FileAccess.Write))
{
document.Save(outputStream, FormatType.Docx);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

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

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

</Project>

0 comments on commit 06b99da

Please sign in to comment.