open method
Contents
[
Hide
]open(fileName)
Allows a COM application to load a Document from a file.
open(fileName: string)
Parameter | Type | Description |
---|---|---|
fileName | string | Filename of the document to load. |
Remarks
This method is same as calling the Document constructor with a file name parameter.
Returns
A Document object that represents a Word document.
open(stream)
Allows a COM application to load Document from a stream.
open(stream: Buffer)
Parameter | Type | Description |
---|---|---|
stream | Buffer | A .NET stream object that contains the document to load. |
Remarks
This method is same as calling the Document constructor with a stream parameter.
Returns
A Document object that represents a Word document.
Examples
Shows how to open documents using the ComHelper class.
// The ComHelper class allows us to load documents from within COM clients.
let comHelper = new aw.ComHelper();
// 1 - Using a local system filename:
let doc = comHelper.open(base.myDir + "Document.docx");
expect(doc.getText().trim()).toEqual("Hello World!\r\rHello Word!\r\r\rHello World!");
// 2 - From a stream:
let stream = base.loadFileToBuffer(base.myDir + "Document.docx");
doc = comHelper.open(stream);
expect(doc.getText().trim()).toEqual("Hello World!\r\rHello Word!\r\r\rHello World!");
See Also
- module Aspose.Words
- class ComHelper