com.aspose.words
Class LoadFormat

java.lang.Object
    extended by 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 specify a base URI when opening an html document.
// Suppose we want to load an .html document that contains an image linked by a relative URI
// while the image is in a different location. In that case, we will need to resolve the relative URI into an absolute one.
// We can provide a base URI using an HtmlLoadOptions object. 
HtmlLoadOptions loadOptions = new HtmlLoadOptions(LoadFormat.HTML, "", getImageDir());

Assert.assertEquals(LoadFormat.HTML, loadOptions.getLoadFormat());

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

// While the image was broken in the input .html, our custom base URI helped us repair the link.
Shape imageShape = (Shape) doc.getChildNodes(NodeType.SHAPE, true).get(0);
Assert.assertTrue(imageShape.isImage());

// This output document will display the image that was missing.
doc.save(getArtifactsDir() + "HtmlLoadOptions.BaseUri.docx");

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 the local file system while converting it to .docx
doc.save(getArtifactsDir() + "Document.InsertHtmlFromWebPage.docx");

Field Summary
static final intAUTO = 0
           Instructs Aspose.Words to recognize the format automatically.
static final intDOC = 10
           Microsoft Word 95 or Word 97 - 2003 Document.
static final intDOT = 11
           Microsoft Word 95 or Word 97 - 2003 Template.
static final intDOC_PRE_WORD_60 = 12
           The document is in pre-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 intCHM = 53
           CHM (Compiled HTML Help) format.
static final intODT = 60
           ODF Text Document.
static final intOTT = 61
           ODF Text Document Template.
static final intTEXT = 62
           Plain Text.
static final intMARKDOWN = 63
           Markdown text document.
static final intPDF = 64
           Pdf document.
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 95 or Word 97 - 2003 Document.

DOT = 11

public static final int DOT
Microsoft Word 95 or Word 97 - 2003 Template.

DOC_PRE_WORD_60 = 12

public static final int DOC_PRE_WORD_60
The document is in pre-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.

CHM = 53

public static final int CHM
CHM (Compiled HTML Help) format.

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.

MARKDOWN = 63

public static final int MARKDOWN
Markdown text document.

PDF = 64

public static final int PDF
Pdf document.

UNKNOWN = 255

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

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.