Click or drag to resize

LoadFormat Enumeration

Indicates the format of the document that is to be loaded.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.9.0

Syntax

public enum LoadFormat

Members

  Member nameValueDescription
Auto0 Instructs Aspose.Words to recognize the format automatically.
Doc10 Microsoft Word 95 or Word 97 - 2003 Document.
Dot11 Microsoft Word 95 or Word 97 - 2003 Template.
DocPreWord6012 The document is in pre-Word 95 format. Aspose.Words does not currently support loading such documents.
Docx20 Office Open XML WordprocessingML Document (macro-free).
Docm21 Office Open XML WordprocessingML Macro-Enabled Document.
Dotx22 Office Open XML WordprocessingML Template (macro-free).
Dotm23 Office Open XML WordprocessingML Macro-Enabled Template.
FlatOpc24 Office Open XML WordprocessingML stored in a flat XML file instead of a ZIP package.
FlatOpcMacroEnabled25 Office Open XML WordprocessingML Macro-Enabled Document stored in a flat XML file instead of a ZIP package.
FlatOpcTemplate26 Office Open XML WordprocessingML Template (macro-free) stored in a flat XML file instead of a ZIP package.
FlatOpcTemplateMacroEnabled27 Office Open XML WordprocessingML Macro-Enabled Template stored in a flat XML file instead of a ZIP package.
Rtf30 RTF format.
WordML31 Microsoft Word 2003 WordprocessingML format.
Html50 HTML format.
Mhtml51 MHTML (Web archive) format.
Mobi52 MOBI is an eBook format used by the MobiPocket Reader and Amazon Kindle Readers.
Odt60 ODF Text Document.
Ott61 ODF Text Document Template.
Text62 Plain Text.
Markdown63 Markdown text document.
Pdf64 Pdf document.
Unknown255 Unrecognized format, cannot be loaded by Aspose.Words.

Examples

Shows how to specify a base URI when opening an html document.
// If we want to load an .html document which contains an image linked by a relative URI
// while the image is in a different location, we will need to resolve the relative URI into an absolute one
// by creating an HtmlLoadOptions and providing a base URI 
HtmlLoadOptions loadOptions = new HtmlLoadOptions(LoadFormat.Html, "", ImageDir);

Assert.AreEqual(LoadFormat.Html, loadOptions.LoadFormat);

Document doc = new Document(MyDir + "Missing image.html", loadOptions);

// While the image was broken in the input .html, it was successfully found in our base URI
Shape imageShape = (Shape)doc.GetChildNodes(NodeType.Shape, true)[0];
Assert.True(imageShape.IsImage);

// The image will be displayed correctly by the output document
doc.Save(ArtifactsDir + "HtmlLoadOptions.BaseUri.docx");
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)))
    {
        // The URL is used again as a baseUri to ensure that any relative image paths are retrieved correctly.
        LoadOptions options = new LoadOptions(LoadFormat.Html, "", url);

        // Load the HTML document from stream and pass the LoadOptions object.
        Document doc = new Document(stream, options);

        // At this stage, we can read and edit the document's contents and then save it to the local file system.
        Assert.AreEqual("File Format APIs", doc.FirstSection.Body.Paragraphs[1].Runs[0].GetText().Trim());

        doc.Save(ArtifactsDir + "Document.InsertHtmlFromWebPage.docx");
    }
}

See Also