Skip to content

Commit 9d9e629

Browse files
Removed the unaddressed samples added existing sample
1 parent 5394c5f commit 9d9e629

File tree

15 files changed

+96
-225
lines changed

15 files changed

+96
-225
lines changed

HTML-conversions/Convert-Webpage-to-Word-document/Convert-Webpage-to-Word-document/Convert-Webpage-to-Word-document.csproj

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

HTML-conversions/Convert-Webpage-to-Word-document/Convert-Webpage-to-Word-document/Program.cs

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

HTML-conversions/Convert-Webpage-to-Word-document/Convert-Webpage-to-Word-document.sln renamed to Word-document/Merge–multiple-Word-files-in-same-page/.NET/Merge–multiple-Word-files-in-same-page.sln

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
4-
VisualStudioVersion = 17.12.35309.182
4+
VisualStudioVersion = 17.8.34322.80
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert-Webpage-to-Word-document", "Convert-Webpage-to-Word-document\Convert-Webpage-to-Word-document.csproj", "{06FE467C-5A79-4EE2-A991-D2A4C81C52C6}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge–multiple-Word-files-in-same-page", "Merge–multiple-Word-files-in-same-page\Merge–multiple-Word-files-in-same-page.csproj", "{C790F761-62BA-49E1-8FF6-E15165CB08C1}"
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-
{06FE467C-5A79-4EE2-A991-D2A4C81C52C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{06FE467C-5A79-4EE2-A991-D2A4C81C52C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{06FE467C-5A79-4EE2-A991-D2A4C81C52C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{06FE467C-5A79-4EE2-A991-D2A4C81C52C6}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{C790F761-62BA-49E1-8FF6-E15165CB08C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{C790F761-62BA-49E1-8FF6-E15165CB08C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{C790F761-62BA-49E1-8FF6-E15165CB08C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{C790F761-62BA-49E1-8FF6-E15165CB08C1}.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 = {2ABFDCB1-6319-40CB-94A9-BF7099E58EF2}
23+
SolutionGuid = {F533289D-7351-4DA3-96EE-B9C18CA8DCDD}
2424
EndGlobalSection
2525
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Merge_multiple_Word_files_in_same_page</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIO.NET" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Data\Addressblock.docx">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Data\Greetings.docx">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
<None Update="Data\Salutation.docx">
23+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
24+
</None>
25+
<None Update="Data\Title.docx">
26+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
27+
</None>
28+
<None Update="Output\.gitkeep">
29+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
30+
</None>
31+
</ItemGroup>
32+
33+
</Project>

HTML-conversions/Convert-Webpage-to-Word-document/Convert-Webpage-to-Word-document/Output/.gitkeep renamed to Word-document/Merge–multiple-Word-files-in-same-page/.NET/Merge–multiple-Word-files-in-same-page/Output/.gitkeep

File renamed without changes.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
4+
//Register Syncfusion license
5+
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Mgo+DSMBMAY9C3t2UlhhQlNHfV5DQmBWfFN0QXNYfVRwdF9GYEwgOX1dQl9nSXZTc0VlWndfcXNSQWc=");
6+
7+
//Get the list of source documents to be imported.
8+
List<string> sourceFileNames = new List<string>();
9+
sourceFileNames.Add("Data/Addressblock.docx");
10+
sourceFileNames.Add("Data/Salutation.docx");
11+
sourceFileNames.Add("Data/Greetings.docx");
12+
13+
//Get the full path of the destination document.
14+
string destinationFileName = Path.GetFullPath(@"Data/Title.docx");
15+
//Open a file stream to the destination document.
16+
using (FileStream destinationStreamPath = new FileStream(destinationFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
17+
{
18+
//Opens the destination document.
19+
using (WordDocument destinationDocument = new WordDocument(destinationStreamPath, FormatType.Automatic))
20+
{
21+
//Calls the method to import other documents into the destination document.
22+
ImportOtherDocuments(sourceFileNames, destinationDocument);
23+
//Saves and closes the destination document.
24+
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.Write))
25+
{
26+
destinationDocument.Save(outputStream, FormatType.Docx);
27+
//Closes the destination document.
28+
destinationDocument.Close();
29+
}
30+
}
31+
}
32+
33+
/// <summary>
34+
/// Import content from multiple source Word documents into a destination document.
35+
/// </summary>
36+
void ImportOtherDocuments(List<string> sourceFiles, WordDocument destinationDocument) //Method to import content from source documents into the destination document
37+
{
38+
//Iterate through each source document from the list.
39+
foreach (string sourceFileName in sourceFiles)
40+
{
41+
//Open the source document.
42+
using (FileStream sourceStreamPath = new FileStream(sourceFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
43+
{
44+
//Opens the Word document from the file stream.
45+
using (WordDocument document = new WordDocument(sourceStreamPath, FormatType.Automatic)) //Initialize a WordDocument object for the source document
46+
{
47+
//Set the break-code of the first section of the source document as NoBreak to avoid starting content on a new page.
48+
document.LastSection.BreakCode = SectionBreakCode.NoBreak;
49+
//Imports the content of the source document at the end of the destination document.
50+
destinationDocument.ImportContent(document, ImportOptions.UseDestinationStyles);
51+
//Close the source document
52+
document.Close();
53+
}
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)