Why to Convert
MHTML (MIME HTML) is a web page archive format used to save web pages for offline viewing. It is a combination of HTML code and resources like images, audio, and video. DOCM is a Microsoft Word Open XML Macro-Enabled Document file format used to store documents with macros. It is a combination of XML elements, macros, and binary data. Converting MHTML to DOCM is necessary to make the web page content available in a format that can be used with Microsoft Word.
How Aspose.Total helps for mhtml to docm conversion
Integrating MHTML to DOCM conversion feature in mobile apps can be done by using two APIs of Aspose.Total for Android Java package. First, Aspose.PDF for Android via Java API can be used to convert MHTML file to DOC. Secondly, Word Processing API Aspose.Words for Android Java can be used to render DOC to DOCM. Aspose.Total for Android Java is a suite of APIs that provides a comprehensive set of file processing features including document conversion, manipulation, and rendering. It is a powerful set of APIs that can be used to create, edit, and convert various file formats in mobile apps.
Convert MHTML to DOCM on Android via Java
Get Started with Android via Java APIs
You can easily use Aspose.Total for Android via Java directly from Maven and install Aspose.PDF for Android via Java and Aspose.Words for Android via Java in your applications.
Alternatively, you can get a ZIP file from downloads .
// load MHTML file with an instance of Document class
Document document = new Document("template.mhtml");
// save MHTML as a DOC
document.save("DocOutput.doc", SaveFormat.DOC);
// load DOC with an instance of Document
Document outputDocument = new com.aspose.words.Document("DocOutput.doc");
// call save method while passing SaveFormat.DOCM
outputDocument.save("output.docm", SaveFormat.DOCM);
Get MHTML File Information on Android via Java
Before converting MHTML to DOCM, you might need information about the document including author, creation date, keywords, modify date, subject, and title. This information is helpful for the decision making for the conversion process. Using the powerful Aspose.PDF for Android via Java API, you can get all of it. To get file-specific information about a MHTML file, first get the DocumentInfo object using getInfo method. Once the DocumentInfo object is retrieved, you can get the values of the individual properties.
// load MHTML document
Document doc = new Document("template.mhtml");
// get document information
DocumentInfo docInfo = doc.getInfo();
// show document information
System.out.println("Author: " + docInfo.getAuthor());
System.out.println("Creation Date: " + docInfo.getCreationDate());
System.out.println("Keywords: " + docInfo.getKeywords());
System.out.println("Modify Date: " + docInfo.getModDate());
System.out.println("Subject: " + docInfo.getSubject());
System.out.println("Title: " + docInfo.getTitle());
Insert Endnotes in DOCM Document in Android Apps
Apart from document conversion, you can also add a bunch of other features inside your Android Applications using Aspose.Words for Android via Java API. One of that feature is inserting endnotes and numbering in DOCM document. If you want to insert a footnote or an endnote in a DOCM document, please use DocumentBuilder.InsertFootnote method. This method inserts a footnote or endnote into the document. EndnoteOptions and FootnoteOptions classes represent numbering options for footnote and endnote.
// load document
Document doc = new Document("input.DOC");
// initialize document builder
DocumentBuilder builder = new DocumentBuilder(doc);
// add text in it
builder.write("Some text");
// insert footnote
builder.insertFootnote(FootnoteType.ENDNOTE, "Endnote text.");
// initialize endnote options
EndnoteOptions option = doc.getEndnoteOptions();
// set restart rule
option.setRestartRule(FootnoteNumberingRule.RESTART_PAGE);
// set position
option.setPosition(EndnotePosition.END_OF_SECTION);
// save the document to disk.
doc.save("output.docm", SaveFormat.DOCM);