We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HTML to DOCX generates corroupted output using VB.NET

hi. when i try to make html to docx. i got a broken file docx

i give you the code and the files result
netaliaPeople.zip (6.9 KB)

	cvHTMLBody = request("inputHTML")
      Dim cvLogo = request("logo")
			if cvHTMLBody = "" then
				cvHTMLBody = " "
			end if

			' ---=== 3. load the HTML ---=== '
			dim stream As new MemoryStream(System.Text.Encoding.UTF8.GetBytes(cvHTMLBody))
			dim options As new LoadOptions()
			options.Encoding = Encoding.GetEncoding(65001)
			options.LoadFormat = LoadFormat.Html
			 options.BaseUri = cvHTMLBody
			Dim doc As new Document(stream, options)
			
			'    New Start
			'-----------------
			if cvLogo <> "" then
				Dim builder As DocumentBuilder = New DocumentBuilder(doc)

        builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary)
        builder.InsertHtml(cvLogo)
        builder.CurrentParagraph.ParagraphFormat.Alignment = 2
        ' builder.InsertImage(cvLogo,ConvertUtil.PixelToPoint(350),ConvertUtil.PixelToPoint(133))
				doc.UpdateFields()
			end if
			'     New End
			'-----------------
			Dim dstStream As New MemoryStream()
			doc.Save(dstStream, SaveFormat.Docx)
      
   
      
			Response.Clear()
			Response.AppendHeader("Content-Type","application/vnd.openxmlformats-officedocument.wordprocessingml.document")
			Response.AppendHeader("Content-Disposition", string.Format("attachment; filename=cv.docx"))
			dstStream.WriteTo(Response.OutputStream) 
			'Response.Close()
			Response.End()

@eranlipi

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input HTML document.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a sample application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.