generated from VeeamHub/veeamhub-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated CHtmlExporter.cs to use Html exportables namespace.
Removed and re-added HtmlToPdfConverter.cs under new namespace. Added DocX and HtmlToOpenXml.dll package references. Disabled PDF export checkbox in VhcGui.xaml.cs for VB365 and VBR. Added CHtmlToDocx.cs for HTML to DOCX conversion.
- Loading branch information
1 parent
6351ce1
commit 9bf6670
Showing
8 changed files
with
87 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
vHC/HC_Reporting/Functions/Reporting/Html/Exportables/CHtmlToDocx.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Controls; | ||
using System; | ||
using System.IO; | ||
using Xceed.Words.NET; | ||
using HtmlToOpenXml; | ||
using DocumentFormat.OpenXml.Packaging; | ||
using DocumentFormat.OpenXml.Wordprocessing; | ||
using DocumentFormat.OpenXml; | ||
|
||
namespace VeeamHealthCheck.Functions.Reporting.Html.Exportables | ||
{ | ||
internal class CHtmlToDocx | ||
{ | ||
public void ExportHtmlToDocx(string htmlContent, string outputPath) | ||
{ | ||
// Create a new document | ||
using (var wordDocument = WordprocessingDocument.Create(outputPath, WordprocessingDocumentType.Document)) | ||
{ | ||
// Add a main document part | ||
var mainPart = wordDocument.AddMainDocumentPart(); | ||
mainPart.Document = new Document(); | ||
var body = new Body(); | ||
mainPart.Document.Append(body); | ||
|
||
// Set the document to landscape mode | ||
var sectionProperties = new SectionProperties(); | ||
var pageSize = new PageSize | ||
{ | ||
Width = 16838, // 11.69 inches in twentieths of a point (A4 landscape width) | ||
Height = 11906, // 8.27 inches in twentieths of a point (A4 landscape height) | ||
Orient = PageOrientationValues.Landscape | ||
}; | ||
var pageMargin = new PageMargin | ||
{ | ||
Top = 720, // 1 inch in twentieths of a point | ||
Right = 720, | ||
Bottom = 720, | ||
Left = 720 | ||
}; | ||
sectionProperties.Append(pageSize); | ||
sectionProperties.Append(pageMargin); | ||
body.Append(sectionProperties); | ||
|
||
// Create a new HtmlConverter | ||
var converter = new HtmlConverter(mainPart); | ||
|
||
// Convert the HTML content to DocX format | ||
converter.ParseBody(htmlContent); | ||
|
||
// Save the document | ||
mainPart.Document.Save(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters