diff --git a/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document.sln b/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document.sln new file mode 100644 index 00000000..991ea622 --- /dev/null +++ b/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.37111.16 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Save-HTML-From-Word-Document", "Save-HTML-From-Word-Document\Save-HTML-From-Word-Document.csproj", "{BFD82BD1-243F-86F6-FB0C-E6FB6CF11614}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BFD82BD1-243F-86F6-FB0C-E6FB6CF11614}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BFD82BD1-243F-86F6-FB0C-E6FB6CF11614}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BFD82BD1-243F-86F6-FB0C-E6FB6CF11614}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BFD82BD1-243F-86F6-FB0C-E6FB6CF11614}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6E0ACDC8-D80C-4DBF-BD66-0BB0FDE4BF92} + EndGlobalSection +EndGlobal diff --git a/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Data/Template.docx b/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Data/Template.docx new file mode 100644 index 00000000..04d45cbc Binary files /dev/null and b/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Data/Template.docx differ diff --git a/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Output/.gitkeep b/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Output/.gitkeep new file mode 100644 index 00000000..5f282702 --- /dev/null +++ b/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Output/OddHeader_0.html b/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Output/OddHeader_0.html new file mode 100644 index 00000000..d6cd59b7 --- /dev/null +++ b/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Output/OddHeader_0.html @@ -0,0 +1,7 @@ +
Created with a trial version of Syncfusion Word library or registered the wrong key in your application. Click here to obtain the valid key.
+Adventure Works Cycles
Created with a trial version of Syncfusion Word library or registered the wrong key in your application. Click here to obtain the valid key.
+ \ No newline at end of file diff --git a/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Output/TextBody.html b/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Output/TextBody.html new file mode 100644 index 00000000..42958bea --- /dev/null +++ b/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Output/TextBody.html @@ -0,0 +1,48 @@ +Created with a trial version of Syncfusion Word library or registered the wrong key in your application. Click here to obtain the valid key.
+Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base.
+In 2000, Adventure Works Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico. Importadores Neptuno manufactures several critical subcomponents for the Adventure Works Cycles product line. These subcomponents are shipped to the Bothell location for final product assembly. In 2001, Importadores Neptuno, became the sole manufacturer and distributor of the touring bicycle product group.
+Mountain-200+Product No: BK-M68B-38 +Size: 38 +Weight: 25 +Price: $2,294.99 ++ + | |
Mountain-300+Product No: BK-M47B-38 +Size: 35 +Weight: 22 +Price: $1,079.99 ++ + | |
Road-150+Product No: BK-R93R-44 +Size: 44 +Weight: 14 +Price: $3,578.27 ++ + |
+
Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base.
++
+
Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base.
+In 2000, Adventure Works Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico. Importadores Neptuno manufactures several critical subcomponents for the Adventure Works Cycles product line. These subcomponents are shipped to the Bothell location for final product assembly. In 2001, Importadores Neptuno, became the sole manufacturer and distributor of the touring bicycle product group.
++
Created with a trial version of Syncfusion Word library or registered the wrong key in your application. Click here to obtain the valid key.
+ \ No newline at end of file diff --git a/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Program.cs b/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Program.cs new file mode 100644 index 00000000..07907913 --- /dev/null +++ b/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Program.cs @@ -0,0 +1,80 @@ +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; + +namespace Save_HTML_From_Word_Document +{ + class Program + { + static void Main(string[] args) + { + //Open the input Word document as a file stream + using (FileStream inputStream = new FileStream(Path.GetFullPath(@"../../../Data/Template.docx"), FileMode.Open, FileAccess.Read)) + { + // Load the Word document + using (WordDocument document = new WordDocument(inputStream, FormatType.Docx)) + { + int i = 0; + // Iterate through each section in the document + foreach (WSection section in document.Sections) + { + // Handle first page header / footer if enabled + if (section.PageSetup.DifferentFirstPage) + { + GenerateHTML(section.HeadersFooters.FirstPageHeader, "FirstPageHeader_" + i + ".html"); + GenerateHTML(section.HeadersFooters.FirstPageFooter, "FirstPageFooter_" + i + ".html"); + } + // Handle even page header / footer if enabled + else if (section.PageSetup.DifferentOddAndEvenPages) + { + GenerateHTML(section.HeadersFooters.EvenHeader, "EvenHeader_" + i + ".html"); + GenerateHTML(section.HeadersFooters.EvenFooter, "EvenFooter_" + i + ".html"); + + } + //This is the default header and footer + GenerateHTML(section.HeadersFooters.OddHeader, "OddHeader_" + i + ".html"); + GenerateHTML(section.HeadersFooters.OddFooter, "OddFooter_" + i + ".html"); + + //After generating headers and footers, clear it + section.HeadersFooters.FirstPageHeader.ChildEntities.Clear(); + section.HeadersFooters.FirstPageFooter.ChildEntities.Clear(); + section.HeadersFooters.EvenHeader.ChildEntities.Clear(); + section.HeadersFooters.EvenFooter.ChildEntities.Clear(); + section.HeadersFooters.OddHeader.ChildEntities.Clear(); + section.HeadersFooters.OddFooter.ChildEntities.Clear(); + + i++; + } + // Save the remaining document body content as HTM + using (FileStream outputStream = new FileStream(Path.GetFullPath(@"../../../Output/TextBody.html"), FileMode.Create)) + { + document.Save(outputStream, FormatType.Html); + } + } + } + } + /// + // Generates an HTML file from the given text body(header or footer). + /// + /// The text body (header/footer) to convert. + /// The output HTML file name. + + private static void GenerateHTML(WTextBody textBody, string outputFile) + { + string outputPath = Path.GetFullPath(@"../../../Output/"); + // Check if the text body contains any content + if (textBody.ChildEntities.Count > 0) + { + // Create a new Word document to hold extracted content + WordDocument document = new WordDocument(); + document.AddSection(); + // Clone and add each entity from the source text body + foreach (Entity entity in textBody.ChildEntities) + document.LastSection.Body.ChildEntities.Add(entity.Clone()); + + //Save the extracted content as an HTML file + document.Save(outputPath + outputFile, FormatType.Html); + } + } + } +} + \ No newline at end of file diff --git a/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document.csproj b/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document.csproj new file mode 100644 index 00000000..5b477f79 --- /dev/null +++ b/HTML-conversions/Save-HTML-From-Word-Document/.NET/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document/Save-HTML-From-Word-Document.csproj @@ -0,0 +1,21 @@ +