diff --git a/examples/Demo/Program.cs b/examples/Demo/Program.cs index 47c0124..0620d54 100644 --- a/examples/Demo/Program.cs +++ b/examples/Demo/Program.cs @@ -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()) @@ -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) @@ -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); } diff --git a/examples/Demo/Resources/Demo.html b/examples/Demo/Resources/Demo.html deleted file mode 100644 index 906b7e4..0000000 --- a/examples/Demo/Resources/Demo.html +++ /dev/null @@ -1,97 +0,0 @@ - - - -
    -
  1. This is H1 -
      -
    1. This is H2
    2. -
    3. Another H2
    4. -
    -
  2. -
  3. This is another H1 -
      -
    1. This is H2
    2. -
    3. Another H2
    4. -
    -
  4. -
  5. Last H1 -
      -
    1. This is H2
    2. -
    3. Another H2
    4. -
    -
  6. -
- -
- - Looks how cool is Open Xml. - Now with HtmlToOpenXml, it nevers been so easy to convert html. -

- If you like it, add me a rating on codeplex -

-
-
public void SetContentType(System.Web.HttpRequest request, System.Web.HttpResponse response, String reportName)
-{
-	if (request.Browser.Browser.Contains("IE"))
-	{
-		// Replace the %20 to obtain a clean name when saving the file from Word.
-		encodedFilename =
-		  Uri.EscapeDataString(Path.GetFileNameWithoutExtension(encodedFilename)).Replace("%20", " ")
-			+ Path.GetExtension(encodedFilename);
-	}
-}
- -
- -

An ordered list:

-
    -
  1. Coffee
  2. -
  3. Tea
  4. -
  5. Milk - -
  6. -
  7. Wine
  8. -
- -

An unordered list:

- diff --git a/examples/Demo/Resources/Demo2.html b/examples/Demo/Resources/Demo2.html deleted file mode 100644 index 50436c0..0000000 --- a/examples/Demo/Resources/Demo2.html +++ /dev/null @@ -1,57 +0,0 @@ -

$#Candidate Code#$

-

 

-

Hello dude

-bonjour je suis du texte en mauve. - - - - - - - - - - - - - - - - - - - - - - - - -
 saa fdgdfg fdg fdgfdg 
    fdg 
  fd fdggfdg  gfdgfd
- -
- - - - - - - - - - - - - - - - - - - - - - - - - -
 saa fdgdfg fdg fdgfdg 
    fdg 
  fd fdggfdg  gfdgfd
\ No newline at end of file