com.aspose.words

Class LoadFormat

  • java.lang.Object
    • com.aspose.words.LoadFormat
public class LoadFormat 
extends java.lang.Object

Utility class containing constants. Indicates the format of the document that is to be loaded.

Example:

Shows how to open older binary DOC format for Word6.0/Word95 documents
LoadOptions loadOptions = new LoadOptions();
loadOptions.setLoadFormat(LoadFormat.DOC_PRE_WORD_60);

Document doc = new Document(getMyDir() + "Document.PreWord60.doc", loadOptions);

Example:

Explicitly loads a document as HTML without automatic file format detection.
LoadOptions loadOptions = new LoadOptions();
loadOptions.setLoadFormat(com.aspose.words.LoadFormat.HTML);
Document doc = new Document(getMyDir() + "Document.LoadFormat.html", loadOptions);

Example:

Shows how to insert the HTML contents from a web page into a new document.
// The url of the page to load
URL url = new URL("http://www.aspose.com/");

// The easiest way to load our document from the internet is make use of the URLConnection class.
URLConnection webClient = url.openConnection();

// Download the bytes from the location referenced by the URL.
InputStream inputStream = webClient.getInputStream();

// Convert the input stream to a byte array.
int pos;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
while ((pos = inputStream.read()) != -1) bos.write(pos);

byte[] dataBytes = bos.toByteArray();

// Wrap the bytes representing the document in memory into a stream object.
ByteArrayInputStream byteStream = new ByteArrayInputStream(dataBytes);

// The baseUri property should be set to ensure any relative img paths are retrieved correctly.
LoadOptions options = new LoadOptions(LoadFormat.HTML, "", url.getPath());

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

// Save the document to disk.
// The extension of the filename can be changed to save the document into other formats. e.g PDF, DOCX, ODT, RTF.
doc.save(getMyDir() + "\\Artifacts\\Document.HtmlPageFromWebpage.doc");

Field Summary
static final intAUTO = 0
Instructs Aspose.Words to recognize the format automatically.
static final intDOC = 10
Microsoft Word 97 - 2007 Document.
static final intDOT = 11
Microsoft Word 97 - 2007 Template.
static final intDOC_PRE_WORD_60 = 12
The document is in the Word 6 or Word 95 format. Aspose.Words does not currently support loading such documents.
static final intDOCX = 20
Office Open XML WordprocessingML Document (macro-free).
static final intDOCM = 21
Office Open XML WordprocessingML Macro-Enabled Document.
static final intDOTX = 22
Office Open XML WordprocessingML Template (macro-free).
static final intDOTM = 23
Office Open XML WordprocessingML Macro-Enabled Template.
static final intFLAT_OPC = 24
Office Open XML WordprocessingML stored in a flat XML file instead of a ZIP package.
static final intFLAT_OPC_MACRO_ENABLED = 25
Office Open XML WordprocessingML Macro-Enabled Document stored in a flat XML file instead of a ZIP package.
static final intFLAT_OPC_TEMPLATE = 26
Office Open XML WordprocessingML Template (macro-free) stored in a flat XML file instead of a ZIP package.
static final intFLAT_OPC_TEMPLATE_MACRO_ENABLED = 27
Office Open XML WordprocessingML Macro-Enabled Template stored in a flat XML file instead of a ZIP package.
static final intRTF = 30
RTF format.
static final intWORD_ML = 31
Microsoft Word 2003 WordprocessingML format.
static final intHTML = 50
HTML format.
static final intMHTML = 51
MHTML (Web archive) format.
static final intMOBI = 52
MOBI is an eBook format used by the MobiPocket Reader and Amazon Kindle Readers.
static final intODT = 60
ODF Text Document.
static final intOTT = 61
ODF Text Document Template.
static final intTEXT = 62
Plain Text
static final intUNKNOWN = 255
Unrecognized format, cannot be loaded by Aspose.Words.
 

    • Field Detail

      • AUTO = 0

        public static final int AUTO
        Instructs Aspose.Words to recognize the format automatically.
      • DOC = 10

        public static final int DOC
        Microsoft Word 97 - 2007 Document.
      • DOT = 11

        public static final int DOT
        Microsoft Word 97 - 2007 Template.
      • DOC_PRE_WORD_60 = 12

        public static final int DOC_PRE_WORD_60
        The document is in the Word 6 or Word 95 format. Aspose.Words does not currently support loading such documents.
      • DOCX = 20

        public static final int DOCX
        Office Open XML WordprocessingML Document (macro-free).
      • DOCM = 21

        public static final int DOCM
        Office Open XML WordprocessingML Macro-Enabled Document.
      • DOTX = 22

        public static final int DOTX
        Office Open XML WordprocessingML Template (macro-free).
      • DOTM = 23

        public static final int DOTM
        Office Open XML WordprocessingML Macro-Enabled Template.
      • FLAT_OPC = 24

        public static final int FLAT_OPC
        Office Open XML WordprocessingML stored in a flat XML file instead of a ZIP package.
      • FLAT_OPC_MACRO_ENABLED = 25

        public static final int FLAT_OPC_MACRO_ENABLED
        Office Open XML WordprocessingML Macro-Enabled Document stored in a flat XML file instead of a ZIP package.
      • FLAT_OPC_TEMPLATE = 26

        public static final int FLAT_OPC_TEMPLATE
        Office Open XML WordprocessingML Template (macro-free) stored in a flat XML file instead of a ZIP package.
      • FLAT_OPC_TEMPLATE_MACRO_ENABLED = 27

        public static final int FLAT_OPC_TEMPLATE_MACRO_ENABLED
        Office Open XML WordprocessingML Macro-Enabled Template stored in a flat XML file instead of a ZIP package.
      • RTF = 30

        public static final int RTF
        RTF format.
      • WORD_ML = 31

        public static final int WORD_ML
        Microsoft Word 2003 WordprocessingML format.
      • HTML = 50

        public static final int HTML
        HTML format.
      • MHTML = 51

        public static final int MHTML
        MHTML (Web archive) format.
      • MOBI = 52

        public static final int MOBI
        MOBI is an eBook format used by the MobiPocket Reader and Amazon Kindle Readers.
      • ODT = 60

        public static final int ODT
        ODF Text Document.
      • OTT = 61

        public static final int OTT
        ODF Text Document Template.
      • TEXT = 62

        public static final int TEXT
        Plain Text
      • UNKNOWN = 255

        public static final int UNKNOWN
        Unrecognized format, cannot be loaded by Aspose.Words.