public class LoadFormat
Example: Example:
// 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, "", 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, it was successfully found in our base URI
Shape imageShape = (Shape) doc.getChildNodes(NodeType.SHAPE, true).get(0);
Assert.assertTrue(imageShape.isImage());
// The image will be displayed correctly by the output document
doc.save(getArtifactsDir() + "HtmlLoadOptions.BaseUri.docx");
// 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 int | AUTO | |
Instructs Aspose.Words to recognize the format automatically.
|
||
static final int | DOC | |
Microsoft Word 95 or Word 97 - 2003 Document.
|
||
static final int | DOT | |
Microsoft Word 95 or Word 97 - 2003 Template.
|
||
static final int | DOC_PRE_WORD_60 | |
The document is in pre-Word 95 format.
Aspose.Words does not currently support loading such documents.
|
||
static final int | DOCX | |
Office Open XML WordprocessingML Document (macro-free).
|
||
static final int | DOCM | |
Office Open XML WordprocessingML Macro-Enabled Document.
|
||
static final int | DOTX | |
Office Open XML WordprocessingML Template (macro-free).
|
||
static final int | DOTM | |
Office Open XML WordprocessingML Macro-Enabled Template.
|
||
static final int | FLAT_OPC | |
Office Open XML WordprocessingML stored in a flat XML file instead of a ZIP package.
|
||
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.
|
||
static final int | FLAT_OPC_TEMPLATE | |
Office Open XML WordprocessingML Template (macro-free) stored in a flat XML file instead of a ZIP package.
|
||
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.
|
||
static final int | RTF | |
RTF format.
|
||
static final int | WORD_ML | |
Microsoft Word 2003 WordprocessingML format.
|
||
static final int | HTML | |
HTML format.
|
||
static final int | MHTML | |
MHTML (Web archive) format.
|
||
static final int | MOBI | |
MOBI is an eBook format used by the MobiPocket Reader and Amazon Kindle Readers.
|
||
static final int | CHM | |
CHM (Compiled HTML Help) format.
|
||
static final int | ODT | |
ODF Text Document.
|
||
static final int | OTT | |
ODF Text Document Template.
|
||
static final int | TEXT | |
Plain Text.
|
||
static final int | MARKDOWN | |
Markdown text document.
|
||
static final int | PDF | |
Pdf document.
|
||
static final int | UNKNOWN | |
Unrecognized format, cannot be loaded by Aspose.Words.
|
public static final int AUTO
public static final int DOC
public static final int DOT
public static final int DOC_PRE_WORD_60
public static final int DOCX
public static final int DOCM
public static final int DOTX
public static final int DOTM
public static final int FLAT_OPC
public static final int FLAT_OPC_MACRO_ENABLED
public static final int FLAT_OPC_TEMPLATE
public static final int FLAT_OPC_TEMPLATE_MACRO_ENABLED
public static final int RTF
public static final int WORD_ML
public static final int HTML
public static final int MHTML
public static final int MOBI
public static final int CHM
public static final int ODT
public static final int OTT
public static final int TEXT
public static final int MARKDOWN
public static final int PDF
public static final int UNKNOWN