Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajkiran SwainRank #165 · 14.4K reputationPosted Apr 29, 2023, 1:51 AM EDT
There are multiple ways to export a web page to Word format. Here are two commonly used methods:
Note: The exported Word document may not look exactly the same as the original web page due to differences in formatting and styling.
Marvin ReidRank #1,963 · 746 reputationPosted May 8, 2023, 2:29 PM EDT
You can take the html and convert it to a word file programmatically through use of the DocumentConverter. Here is an example:
using (DocumentConverter documentConverter = new DocumentConverter()) { var input = @"C:\Input\input.html"); var output = @"C:\Output\output.docx"); var jobData = DocumentConverterJobs.CreateJobData(input, output, DocumentFormat.Docx); jobData.JobName = "Convert to Word File"; var documentWriter = new DocumentWriter(); documentConverter.SetDocumentWriterInstance(documentWriter); var renderingEngine = new AnnWinFormsRenderingEngine(); documentConverter.SetAnnRenderingEngineInstance(renderingEngine); var job = documentConverter.Jobs.CreateJob(jobData); documentConverter.Jobs.RunJob(job); }https://www.leadtools.com/help/sdk/tutorials/dotnet-fx-winforms-convert-files-with-the-document-converter.html
Amit KumarRank #459 · 5.4K reputationPosted May 9, 2023, 1:15 AM EDT
Hi,
// Load HTML file using Document class
Document document = new Document(@"C:\Files\sample.html");
// Convert HTML file to Word DOCX format
document.Save(@"C:\Files\output.docx", SaveFormat.Docx);
For more details:
https://www.c-sharpcorner.com/UploadFile/d2dcfc/convert-html-to-word-then-word-to-pdf-with-C-Sharp/
https://blog.conholdate.com/total/convert-html-to-word-document-using-csharp/
https://gist.github.com/farhan-raza/58c356ba2c5354ad9a5c6d3405d43eef
Vishal YelveRank #178 · 13.6K reputationPosted May 9, 2023, 2:24 AM EDT
Hi Thang,
Please check the below links
https://www.c-sharpcorner.com/UploadFile/d2dcfc/convert-html-to-word-then-word-to-pdf-with-C-Sharp/
https://blog.aspose.com/html/convert-html-webpage-to-word-docx-csharp/
https://stackoverflow.com/questions/38567795/convert-html-to-word-using-c-sharp
https://gist.github.com/farhan-raza/58c356ba2c5354ad9a5c6d3405d43eef
https://social.msdn.microsoft.com/Forums/en-US/e8a5069f-7ea0-4964-bbde-32651d931544/how-convert-html-to-doc-in-c?forum=aspwebforms