Aspose.Total for .NET is a comprehensive suite of APIs that provides powerful document manipulation and conversion features for .NET applications. It includes the Aspose.PDF for .NET API, which enables developers to convert XPS file formats to DOC. This API is equipped with advanced features such as the ability to extract text from PDF documents, create and manipulate PDF documents, and convert PDF documents to other popular file formats.
The Aspose.Words for .NET API is a powerful document processing API that enables developers to render DOC files to MHTML. This API provides a wide range of features such as the ability to create, edit, and convert documents, as well as the ability to insert and extract text from documents. It also supports a variety of document formats, including DOC, DOCX, RTF, HTML, and MHTML.
Aspose.Total for .NET is a great choice for developers who need to add document manipulation and conversion features to their .NET applications. With the Aspose.PDF for .NET API, developers can easily convert XPS file formats to DOC. And with the Aspose.Words for .NET API, developers can render DOC files to MHTML. This comprehensive suite of APIs provides developers with the tools they need to create powerful document manipulation and conversion features for their .NET applications.
C# API to Convert XPS to MHTML
Get Started with .NET File Format APIs
Install from command line as
nuget install Aspose.Total or via Package Manager Console of Visual Studio with
Alternatively, get the offline MSI installer or DLLs in a ZIP file from downloads .
Document document = new Document("template.xps"); // save XPS as a DOC document.Save("DocOutput.doc", SaveFormat.Doc); // load Doc with an instance of Document var outputDocument = new Aspose.Words.Document("DocOutput.doc"); // call save method while passing SaveFormat.Mhtml outputDocument.Save("output.mhtml", SaveFormat.Mhtml);
Decrypt XPS File using Owner Password via .NET
Before converting XPS to MHTML, if you want to decrypt your document you can do it by using the API. In order to decrypt the PDF file, you first need to create a Document object and open the XPS using the owner’s password. After that, you need to call Decrypt method of the Document object. Finally, save the updated file using Save method of the Document object.
Document document = new Document("Decrypt.xps", "password"); // decrypt XPS document.Decrypt(); // save the decrypted document as doc document.Save("Decrypt_out.doc");
Create ReadOnly MHTML- File via .NET
In order to protect your MHTML from editing and to prevent other people from editing sensitive and confidential information in your document, you can also set the protection of the document using the API. You can limit the ability to edit a document and only allow certain actions with it. This can be done using Aspose.Words for .NET API. It enables you to control the way you restrict the content using the ProtectionType enumeration parameter. You can set your document to read-only by using the following lines of code.
Document document = new Document("input.doc"); // apply document protection and set protection password doc.Protect(ProtectionType.ReadOnly, "password"); // call save method while passing SaveFormat.Mhtml document.Save("output.mhtml", SaveFormat.Mhtml);
Explore XPS Conversion Options with .NET
What is XPS File Format?
XPS, short for XML Paper Specification, is a file format created by Microsoft to represent fixed-layout documents. XPS files contain the content and print settings of a document, making them suitable for preserving the layout and appearance of a document across different devices and platforms.
The XPS format is based on XML (eXtensible Markup Language), a widely used markup language for structured data representation. XPS files encapsulate document content, such as text, images, vector graphics, and annotations, in a structured XML format. This enables easy interpretation and rendering of the document’s visual elements.
XPS files are conceptually similar to PDF (Portable Document Format) files in that they both aim to provide a reliable way to present and share documents while preserving their formatting and layout. However, PDF files have gained broader support across different software applications and hardware devices, making them more widely accepted and compatible.
To view and work with XPS files, Microsoft provides an XPS Viewer as part of the Windows operating system. Various third-party applications and tools also offer support for opening, creating, and converting XPS files. However, compared to PDF, the range of software and hardware supporting the XPS format may be more limited.
What is MHTML File Format?
MHTML files are often created by web browsers when users save web pages for offline viewing or archiving purposes. By bundling all the necessary resources into one file, MHTML ensures that the web page can be viewed and rendered accurately, even without an internet connection or access to the original server.
The MHTML format follows the MIME standard, which is used for encoding and exchanging various types of data over the internet. It uses multipart MIME encoding to package the HTML code and associated resources into a single file. The file typically has a .mht or .mhtml file extension.
MHTML files can be opened and viewed by web browsers that support the format, such as Internet Explorer, Microsoft Edge, and Opera. Some text editors and specialized software also provide the ability to open and edit MHTML files.
The MHTML format offers advantages in terms of portability and convenience, as it allows users to save and share web pages as a single file, ensuring the preservation of the page’s layout, formatting, and linked resources. However, it’s worth noting that MHTML is not as widely used as other web formats like HTML or PDF, and compatibility may vary across different software and platforms.