How to convert Word to Html in asp.net (WORD components are not required)

Source: Internet
Author: User

Basic Ideas:
Upload a Word file to the server, read its content and store it as Html, and then load the Html content.

1: Use the Microsoft. Office. Interop. Word component
This is a common method, and the code will not be pasted out. There are a lot of examples on the Internet.
Disadvantage: the server needs to install the Word component and set the Docm + object permission on the server. If one server is okay, it is cumbersome to apply the project to multiple different servers.
2: OpenXml API
You can convert .docx (word 97-2003 is not applicable) to XML. It is no longer a problem to convert it to HTML or other formats. This Api requires. net FreamWork3.5 + Office2007 +
3: Third-Party: for example, Aspose. Words (tested and recommended)
Aspose provides various format conversion solutions. If you are interested, please take a closer look ,. NET Java, which adopts Aspose. words this Dll, without installing Microsoft Office components can be converted Word (Converting DOC, docx to HTML without MS Office Word in. net)
Copy codeThe Code is as follows:
Aspose. Words. Document d = new Aspose. Words. Document (wordPhysicalPath );
D. Save ("d: \ 1.html", SaveFormat. Html );

You can save it as an HTML document (note that the images in the Word are stored in the same directory as the Html file, and you need to replace Advantage: you do not need to install the Microsoft Office component. You only need a DLL of about 2 MB to complete this function.
Disadvantage: Aspose is not an open-source component. Although there is a cracked version in China, it can be decompiled and modified by itself. However, the copyright issue is indeed a factor to consider.

There are other third-party projects, most of which are charged, which will not be listed here.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.