LoadFormat enumeration

LoadFormat enumeration

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

Members

NameDescription
AutoInstructs Aspose.Words to recognize the format automatically.
MsWorksMicrosoft Works 8 Document.
DocMicrosoft Word 95 or Word 97 - 2003 Document.
DotMicrosoft Word 95 or Word 97 - 2003 Template.
DocPreWord60The document is in pre-Word 95 format. Aspose.Words does not currently support loading such documents.
DocxOffice Open XML WordprocessingML Document (macro-free).
DocmOffice Open XML WordprocessingML Macro-Enabled Document.
DotxOffice Open XML WordprocessingML Template (macro-free).
DotmOffice Open XML WordprocessingML Macro-Enabled Template.
FlatOpcOffice Open XML WordprocessingML stored in a flat XML file instead of a ZIP package.
FlatOpcMacroEnabledOffice Open XML WordprocessingML Macro-Enabled Document stored in a flat XML file instead of a ZIP package.
FlatOpcTemplateOffice Open XML WordprocessingML Template (macro-free) stored in a flat XML file instead of a ZIP package.
FlatOpcTemplateMacroEnabledOffice Open XML WordprocessingML Macro-Enabled Template stored in a flat XML file instead of a ZIP package.
RtfRTF format.
WordMLMicrosoft Word 2003 WordprocessingML format.
HtmlHTML format.
MhtmlMHTML (Web archive) format.
MobiMOBI format. Used by MobiPocket reader and Amazon Kindle readers.
ChmCHM (Compiled HTML Help) format.
Azw3AZW3 format. Used by Amazon Kindle readers.
EpubEPUB format.
OdtODF Text Document.
OttODF Text Document Template.
TextPlain Text.
MarkdownMarkdown text document.
PdfPdf document.
XmlXML document.
UnknownUnrecognized format, cannot be loaded by Aspose.Words.

Examples

Shows how save a web page as a .docx file.

const url = "https://products.aspose.com/words/";
const response = await fetch(url);
const blob = await response.blob();
const arrayBuffer = await blob.arrayBuffer();
const dataBytes = Buffer.from(arrayBuffer);    

let doc = new aw.Document(dataBytes);

// At this stage, we can read and edit the document's contents and then save it to the local file system.

doc.save(base.artifactsDir + "Document.LoadFromWeb.docx");

Shows how to use the FileFormatUtil methods to detect the format of a document.

// Load a document from a file that is missing a file extension, and then detect its file format.
let docStream = base.loadFileToBuffer(base.myDir + "Word document with missing file extension");
let info = aw.FileFormatUtil.detectFileFormat(docStream);
let loadFormat = info.loadFormat;
expect(loadFormat).toEqual(aw.LoadFormat.Doc);
// Below are two methods of converting a LoadFormat to its corresponding SaveFormat.
// 1 -  Get the file extension string for the LoadFormat, then get the corresponding SaveFormat from that string:
let fileExtension = aw.FileFormatUtil.loadFormatToExtension(loadFormat);
let saveFormat = aw.FileFormatUtil.extensionToSaveFormat(fileExtension);
// 2 -  Convert the LoadFormat directly to its SaveFormat:
saveFormat = aw.FileFormatUtil.loadFormatToSaveFormat(loadFormat);
// Load a document from the stream, and then save it to the automatically detected file extension.
let doc = new aw.Document(docStream);
expect(aw.FileFormatUtil.saveFormatToExtension(saveFormat)).toEqual(".doc");
doc.save(base.artifactsDir + "File.SaveToDetectedFileFormat" + aw.FileFormatUtil.saveFormatToExtension(saveFormat));

See Also