Indicates the format of the document that is to be loaded.
Namespace:
Aspose.Words
Assembly:
Aspose.Words (in Aspose.Words.dll) Version: 21.2.0
Syntax
Public Enumeration LoadFormat
public enum class LoadFormat
Members
| Member name | Value | Description |
---|
| Auto | 0 |
Instructs Aspose.Words to recognize the format automatically.
|
| Doc | 10 |
Microsoft Word 95 or Word 97 - 2003 Document.
|
| Dot | 11 |
Microsoft Word 95 or Word 97 - 2003 Template.
|
| DocPreWord60 | 12 |
The document is in pre-Word 95 format.
Aspose.Words does not currently support loading such documents.
|
| Docx | 20 |
Office Open XML WordprocessingML Document (macro-free).
|
| Docm | 21 |
Office Open XML WordprocessingML Macro-Enabled Document.
|
| Dotx | 22 |
Office Open XML WordprocessingML Template (macro-free).
|
| Dotm | 23 |
Office Open XML WordprocessingML Macro-Enabled Template.
|
| FlatOpc | 24 |
Office Open XML WordprocessingML stored in a flat XML file instead of a ZIP package.
|
| FlatOpcMacroEnabled | 25 |
Office Open XML WordprocessingML Macro-Enabled Document stored in a flat XML file instead of a ZIP package.
|
| FlatOpcTemplate | 26 |
Office Open XML WordprocessingML Template (macro-free) stored in a flat XML file instead of a ZIP package.
|
| FlatOpcTemplateMacroEnabled | 27 |
Office Open XML WordprocessingML Macro-Enabled Template stored in a flat XML file instead of a ZIP package.
|
| Rtf | 30 |
RTF format.
|
| WordML | 31 |
Microsoft Word 2003 WordprocessingML format.
|
| Html | 50 |
HTML format.
|
| Mhtml | 51 |
MHTML (Web archive) format.
|
| Mobi | 52 |
MOBI is an eBook format used by the MobiPocket Reader and Amazon Kindle Readers.
|
| Chm | 53 |
CHM (Compiled HTML Help) format.
|
| Odt | 60 |
ODF Text Document.
|
| Ott | 61 |
ODF Text Document Template.
|
| Text | 62 |
Plain Text.
|
| Markdown | 63 |
Markdown text document.
|
| Pdf | 64 |
Pdf document.
|
| Unknown | 255 |
Unrecognized format, cannot be loaded by Aspose.Words.
|
Examples
Shows how save a web page as a .docx file.
const string url = "http://www.aspose.com/";
using (WebClient client = new WebClient())
{
using (MemoryStream stream = new MemoryStream(client.DownloadData(url)))
{
LoadOptions options = new LoadOptions(LoadFormat.Html, "", url);
Document doc = new Document(stream, options);
doc.Save(ArtifactsDir + "Document.InsertHtmlFromWebPage.docx");
}
}
Shows how to specify a base URI when opening an html document.
HtmlLoadOptions loadOptions = new HtmlLoadOptions(LoadFormat.Html, "", ImageDir);
Assert.AreEqual(LoadFormat.Html, loadOptions.LoadFormat);
Document doc = new Document(MyDir + "Missing image.html", loadOptions);
Shape imageShape = (Shape)doc.GetChildNodes(NodeType.Shape, true)[0];
Assert.True(imageShape.IsImage);
doc.Save(ArtifactsDir + "HtmlLoadOptions.BaseUri.docx");
Shows how to use the FileFormatUtil methods to detect the format of a document.
using (FileStream docStream = File.OpenRead(MyDir + "Word document with missing file extension"))
{
FileFormatInfo info = FileFormatUtil.DetectFileFormat(docStream);
LoadFormat loadFormat = info.LoadFormat;
Assert.AreEqual(LoadFormat.Doc, loadFormat);
string fileExtension = FileFormatUtil.LoadFormatToExtension(loadFormat);
SaveFormat saveFormat = FileFormatUtil.ExtensionToSaveFormat(fileExtension);
saveFormat = FileFormatUtil.LoadFormatToSaveFormat(loadFormat);
Document doc = new Document(docStream);
Assert.AreEqual(".doc", FileFormatUtil.SaveFormatToExtension(saveFormat));
doc.Save(ArtifactsDir + "File.SaveToDetectedFileFormat" + FileFormatUtil.SaveFormatToExtension(saveFormat));
}
See Also