Hi i am developing a customer agreement form where i have Company logo and name on top and rest details in body with terms and condition,
i have created that all sting in with help of string builder and then replace spacific data from database,
now i want to convert ouput string in word file,
i have tried following code but after converting logo and word is not proper format.
- //build the content for the dynamic Word document
- //in HTML alongwith some Office specific style properties.
- var strBody = new StringBuilder();
- strBody.Append(" +
- "xmlns:o='urn:schemas-microsoft-com:office:office' " +
- "xmlns:w='urn:schemas-microsoft-com:office:word'" +
- "xmlns='http://www.w3.org/TR/REC-html40'>" +
- "
Time "); - //The setting specifies document's view after it is downloaded as Print
- //instead of the default Web Layout
- strBody.Append("");
- strBody.Append("");
- strBody.Append("" +
- "");");
- strBody.Append(HtmlCAF);
- strBody.Append("
- //Force this content to be downloaded
- //as a Word document with the name of your choice
- Response.AppendHeader("Content-Type", "application/msword");
- Response.AppendHeader("Content-disposition", "attachment; filename=" + fileName + "");
- Response.Write(strBody.ToString());
please help


Jefferson S. MottaRank #207 · 11.7K reputationPosted May 22, 2020, 3:50 AM EDT
Marvin ReidRank #1,963 · 746 reputationPosted Jan 11, 2023, 3:11 PM EST
You can take string and convert it into a new word document using the Document Editor. Below you can find code that highlights this, as well as the full example in the documentation.
addText = () => { //Allows the user to insert text at cursor location in the document with a prompt instead of typing in the document. var input: string = prompt("Enter in the text you want to add") editor.engine.text.insertText("\n" + input); } exportAsDocx = () => { //exports the current document for saving var promise = editor.document.toFile("untitled", lt.Document.Writer.DocumentFormat.docx); var err = null; promise.then(function (name: string) { }); promise.catch(function (err: string) { alert("There was an issue exporting the document. " + err); }); }https://www.leadtools.com/help/sdk/dh/javascript/de/textengine.html