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()