Skip to content

Commit

Permalink
Update sample project
Browse files Browse the repository at this point in the history
  • Loading branch information
onizet committed Oct 12, 2024
1 parent 84dc9f2 commit c9c719e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 161 deletions.
13 changes: 6 additions & 7 deletions examples/Demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static class Program
static async Task Main(string[] args)
{
const string filename = "test.docx";
string html = ResourceHelper.GetString("Resources.AdvancedTable.html");
string html = ResourceHelper.GetString("Resources.CompleteRunTest.html");
if (File.Exists(filename)) File.Delete(filename);

using (MemoryStream generatedDocument = new MemoryStream())
Expand All @@ -28,8 +28,8 @@ static async Task Main(string[] args)
}

generatedDocument.Position = 0L;
using (WordprocessingDocument package = WordprocessingDocument.Open(generatedDocument, true))
//using (WordprocessingDocument package = WordprocessingDocument.Create(generatedDocument, WordprocessingDocumentType.Document))
//using (WordprocessingDocument package = WordprocessingDocument.Open(generatedDocument, true))
using (WordprocessingDocument package = WordprocessingDocument.Create(generatedDocument, WordprocessingDocumentType.Document))
{
MainDocumentPart mainPart = package.MainDocumentPart;
if (mainPart == null)
Expand All @@ -38,12 +38,11 @@ static async Task Main(string[] args)
new Document(new Body()).Save(mainPart);
}

HtmlConverter converter = new HtmlConverter(mainPart);
HtmlConverter converter = new(mainPart, new HtmlToOpenXml.IO.DefaultWebRequest(){
BaseImageUrl = new Uri(Path.Combine(Environment.CurrentDirectory, "images"))
});
converter.RenderPreAsTable = true;
Body body = mainPart.Document.Body;

await converter.ParseBody(html);
mainPart.Document.Save();

AssertThatOpenXmlDocumentIsValid(package);
}
Expand Down
97 changes: 0 additions & 97 deletions examples/Demo/Resources/Demo.html

This file was deleted.

57 changes: 0 additions & 57 deletions examples/Demo/Resources/Demo2.html

This file was deleted.

0 comments on commit c9c719e

Please sign in to comment.