This topic describes the APIs that are related to the Document object of text documents.
Document
ActiveDocument
Returns the active document.
Syntax expression.ActiveDocument expression: the document type application object.
Method
ActiveDocument.BuiltinDocumentProperties()
You can obtain all built-in properties of a document by using the BuiltinDocumentProperties() method.
Syntax:
expression.ActiveDocument.BuiltinDocumentProperties({Name})expression: the document type application object.
Parameters
Property
Type
Required
Description
Name
string
Yes
The names of the built-in document properties:
Title: The title.
Security: The security value.
Size: The size.
Author: The author.
CorpId: The ID of the corporation.
Guid: The ID of the safe document.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Title property. const title = await app.ActiveDocument.BuiltinDocumentProperties('Title'); console.log(Title); }
ActiveDocument.ExportAsFixedFormat()
By using the ExportAsFixedFormat() method, you can export the current text document as either a PDF document or an IMG image and obtain the URL of the exported file.
Syntax
expression.ActiveDocument.ExportAsFixedFormat({ OutputFileName, ExportFormat })expression: the document type application object.
Parameters
Property
Type
Required
Description
OutputFileName
String
No
The name of the exported file. Not supported in the current version.
ExportFormat
Enum
No
The format of the exported file. Only images and PDF files can be exported. For more information, see WdExportFormat.
OpenAfterExport
Boolean
No
Opens the new file after exporting the contents. Not supported in the current version.
OptimizeFor
Enum
No
Specifies whether to optimize for screen or print. Not supported in the current version. For more information, see WdExportOptimizeFor.
Range
Enum
No
Specifies the range to export. For more information, see WdExportRange.
From
Number
No
Specifies the starting page number, if the Range parameter is set to wdExportFromTo.
To
Number
No
Specifies the ending page number, if the Range parameter is set to wdExportFromTo.
Item
Enum
No
Specifies whether the export process includes text only or includes text with markup. For more information, see WdGoToItem.
IncludeDocProps
Boolean
No
Specifies whether to include document properties in the newly exported file. Valid values:
true (default value)
false
KeepIRM
Boolean
No
Specifies whether to copy Information Rights Management (IRM) permissions to an XPS document if the source document has IRM protection. Not supported in the current version. Valid values:
true (default value)
false
CreateBookmarks
Enum
No
Specifies whether to export bookmarks and the type of bookmarks to export. Not supported in the current version. For more information, see WdExportCreateBookmarks.
DocStructureTags
Boolean
No
Specifies whether to include extra data to help screen readers, for example information about the flow and logical organization of the content. Valid values:
true (default value)
false
BitmapMissingFonts
Boolean
No
Specifies whether to include a bitmap of the text. Not supported in the current version. Valid values:
true: Fonts are not allowed to be embedded in the PDF file. This is the default value.
false: The font is referenced, and the viewer's computer substitutes an appropriate font if the authored one is not available.
UseISO19005_1
Boolean
No
Specifies whether to limit PDF usage to the PDF subset standardized as ISO 19005-1. Not supported in the current version. Valid values:
false (default value)
true The resulting files are more reliably self-contained but may be larger or show more visual artifacts due to the restrictions of the format.
FixedFormatExtClassPtr
Enum
No
Specifies a pointer to an add-in that allows calls to an alternate implementation of code. The alternate implementation of code interprets the EMF and EMF+ page descriptions that are generated by the applications to make their own PDF or XPS. Not supported in the current version.
Dpi
Number
No
The Dots per inch (DPI) of the exported image. Default value: 92.
Combine2LongPic
Boolean
No
Specifies whether to export the file as a long image. Valid values:
false (default value)
true
ImgFormat
Enum
No
Specifies the format of the exported image. For more information, see WdExportImgFormat.
WaterMark
Boolean
No
Specifies whether to add watermarks to the exported file. Valid values:
false (default value)
true
Return values
Returns the URL of the exported file.
Example
Export as PDF
async function example() { await instance.ready(); const app = instance.Application; //Export as a PDF file and obtain the URL of the PDF file. const pdfUrl=await app.ActiveDocument.ExportAsFixedFormat(); // Export as a PDF file by default. console.log(pdfUrl); }Export as Image
async function example() { await instance.ready(); const app = instance.Application; // Export as an image and obtain the URL of the image. const imgUrl=await app.ActiveDocument.ExportAsFixedFormat({ ExportFormat: app.Enum.WdExportFormat.wdExportFormatIMG }); // You can also set the parameter to 19. console.log(imgUrl); }
ActiveDocument.GetAtList()
You can obtain a list of users that are mentioned after an at sign (@) by using the GetAtList() method.
Syntax
expression.ActiveDocument.GetAtList()expression: the document type application object.
Return values
Returns a list of users that are mentioned after an at sign (@) and the corresponding
uuid.Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the list of users that are mentioned after an at sign (@). const atInfo = await app.ActiveDocument.GetAtList(); console.log(atInfo); }
ActiveDocument.GetAtPos()
You can obtain the Range object of a user that is mentioned after an at sign (@) based on the UUID of the user by using the GetAtPos() method.
Syntax
expression.ActiveDocument.GetAtPos({ Uuid })expression: the document type application object.
Parameters
The UUID of a user that is mentioned after an at sign (@).
Property
Type
Required
Description
Uuid
string
Yes
The UUID of an at sign (@).
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the Range object of a user that is mentioned after an at sign (@) based on the UUID of the user. const range = await app.ActiveDocument.GetAtPos(); console.log(range); }
ActiveDocument.GetContainerAttributes()
You can obtain the size of the container of the text by using the GetContainerAttributes() method.
Only JS-SDK V1.1.10 and later support this feature.
Syntax
expression.ActiveDocument.GetContainerAttributes()expression: the document type application object.
Return values
Property
Type
Description
Width
Number
The width of the container.
Height
Number
The height of the container.
OffsetLeft
Number
The distance between the left outer edge of the item and the left inner edge of offsetParent. Unit: pixels.
OffsetTop
Number
The distance between the top outer edge of the item and the top inner edge of offsetParent. Unit: pixels.
ClientWidth
Number
The inner width of the item.
ClientHeight
Number
The inner height of the item.
OffsetWidth
Number
The layout width of the item.
OffsetHeight
Number
The layout height of the item.
ScrollTop
Number
The distance from the top of the item to the topmost visible content.
ScrollLeft
Number
The distance from the top of the item to the leftmost visible content.
ScrollHeight
Number
The height of the content of the item.
ScrollWidth
Number
The width of the content of the item.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the size of the container of the text. const info = await app.ActiveDocument.GetContainerAttributes(); console.log(info); }
ActiveDocument.GetDocumentRange()
You can obtain the range of the text by using the GetDocumentRange() method.
Only JS-SDK V1.1.14 and later support this feature.
Syntax
expression.ActiveDocument.GetDocumentRange()expression: the document type application object.
Return values
Returns a Range object that represents the range of the text.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the range of the text. const range = await app.ActiveDocument.GetDocumentRange(); console.log(range); }
ActiveDocument.GetOperatorsInfo()
You can obtain the information about the current operator by using the GetOperatorsInfo() method.
Syntax
expression.ActiveDocument.GetOperatorsInfo()expression: the document type application object.
Return values
Property
Type
Description
type
String
The type of the request.
response
Object
The information about the operator.
Description of response
Property
Type
Description
id
String
The ID of the user.
avatar_url
Object
The profile picture of the user.
logined
Object
The logon status of the user.
name
Object
The name of the user.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Obtain the information about the current operator. const operatorsInfo = await app.ActiveDocument.GetOperatorsInfo(); console.log(operatorsInfo); }
ActiveDocument.GetOnlineCooperatorList()
You can obtain a list of online cooperators by using the GetOnlineCooperatorList() method.
Syntax
expression.ActiveDocument.GetOnlineCooperatorList()expression: the document type application object.
Return values
Array.<Object>Property
Type
Description
Avatar
String
The URL of the profile picture of the user.
UserName
String
The username of the user.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Obtain a list of online cooperators. const operatorsInfo = await app.ActiveDocument.GetOnlineCooperatorList(); console.log(operatorsInfo); }
ActiveDocument.GetViewMode()
You can obtain the view mode of the current page by using the GetViewMode() method.
Only JS-SDK V1.1.14 and later support this feature.
Syntax
expression.ActiveDocument.GetViewMode()expression: the document type application object.
Return values
The return value
webindicates web layout view andpagesindicates page layout view.Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the view mode of the current page. const mode = await app.ActiveDocument.GetViewMode(); console.log(mode); }
ActiveDocument.GetWatermark()
You can obtain the watermark in a safe document by using the GetWatermark() method.
Syntax
expression.ActiveDocument.GetWatermark()expression: the document type application object.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Obtain the watermark in the safe document. const watermarkInfo = await app.ActiveDocument.GetWatermark(); console.log(watermarkInfo); }
ActiveDocument.ImportDataIntoFields()
You can match and replace content in a document based on the input data and configurations by using the ImportDataIntoFields() method.
Syntax
expression.ActiveDocument.ImportDataIntoFields({ Data, Options })expression: the document type application object.
Parameters
The UUID of a user that is mentioned after an at sign (@).
Property
Type
Required
Description
Data
Object
Yes
Single, multiple, or nested fields. Multiple fields are copied, pasted, and then replaced in batches. For nested fields, keys are concatenated.
ImportantOnly the
Data: { content: value }format is supported.Options
Object
No
The configurations that are imported. Only the
Options: { keyword: 1}format is supported.Example
async function example() { await instance.ready(); const app = instance.Application; // Match and replace content in a document based on the input data and configurations. // If the content is not found, the data are inserted at the end of the text. // In this example, the Title of the content control is jssdk. await app.ActiveDocument.ImportDataIntoFields({ Data: { 'jssdk': 'jssdk2', }, Options: { keyword: 1, }, }); }
ActiveDocument.ReplaceText()
You can match and replace text based on the input array by using the ReplaceText() method.
Only JS-SDK V1.1.10 and later support this feature.
Syntax
expression.ActiveDocument.ReplaceText(Array.<Object>)expression: the document type application object.
Parameters
The input array that represents a list of texts that you want to replace.
Property
Type
Required
Description
list
Array.<Object>
Yes
The list of texts that you want to replace.
Description of list
Property
Type
Required
Description
key
String
Yes
The text to be removed.
value
String
Yes
The text to add.
options
Object
No
The configuration of replacement.
Description of options
Property
Type
Required
Description
isWildcardMatched
Boolean
No
Specifies whether to use wildcards. Asterisks (*) and question marks (?) are supported as wildcards.
Asterisk (*): a string.
Question mark (?): a single character that must exist.
Valid values:
true
false (default value)
isCaseSensitive
Boolean
No
Specifies whether the text is case-sensitive. Valid values:
true (default value)
false
isWholeWordMatched
Boolean
No
Specifies whether to match the whole word. Valid values:
true (default value)
false
isWidthIgnored
Boolean
No
Specifies whether to distinguish full-width and half-width characters. Valid values:
true (default value)
false
Return values
The return value
trueindicates that the replacement is successful andfalseindicates that the replacement failed.Example
async function example() { await instance.ready(); const app = instance.Application; // Replace the text. const isSuccess = await app.ActiveDocument.ReplaceText([ { key: 'Aliyun', value: 'js-sdk', }, ]); console.log(isSuccess); // true }
ActiveDocument.Save()
You can save changes to a document by using the Save() method.
Only JS-SDK V1.1.10 and later support this feature.
Syntax
expression.ActiveDocument.Save()expression: the document type application object.
Return values
Property
Type
Description
result
String
The save status of the file.
size
Number
The size of the file. Unit: byte.
version
Number
The version number.
Description of save status
Save status
Description
ok
The version is saved. You can view the version in Version History.
nochange
No update to save.
SavedEmptyFile
You cannot save an empty file. Scenario: The file is empty after kernel save.
SpaceFull
The disk space is full.
QueneFull
Do not perform frequent operations while saving. Scenario: The server processing and saving queue is full and the saving operation is enqueued.
fail
Failed to save.
Example
async function example() { await instance.ready(); const app = instance.Application; // Save the changes to the file. const save = await app.ActiveDocument.Save(); console.log(save); }
ActiveDocument.SetReadOnly()
You can temporarily set the active document to read-only by using the SetReadOnly() method.
Only JS-SDK V1.1.10 and later support this feature.
Only the active document on the current tab is temporarily set to read-only, and the read-only status ends after you refresh the document.
Only documents for which you are granted permissions to edit can be set to read-only.
You cannot set a document for which you have read-only permissions to editable.
Syntax
expression.ActiveDocument.SetReadOnly({ Value })expression: the document type application object.
Parameters
Property
Type
Required
Description
Value
Boolean
Yes
Specifies whether to set the document to read-only. Valid values:
true
false
Example
async function example() { await instance.ready(); const app = instance.Application; // Set the document to read-only. await app.ActiveDocument.SetReadOnly({ Value: true, }); }
ActiveDocument.ScrollTo()
You can scroll the container of the text to a position by using the ScrollTo() method.
Only JS-SDK V1.1.14 and later support this feature.
Syntax
expression.ActiveDocument.ScrollTo({ ScrollLeft, ScrollTop })expression: the document type application object.
Parameters
Property
Type
Required
Description
ScrollLeft
Number
Yes
Horizontal scroll distance.
ScrollTop
Number
Yes
Vertical scroll distance.
Example
async function example() { await instance.ready(); const app = instance.Application; // Scroll the container of the text to the specified position. await app.ActiveDocument.ScrollTo({ ScrollLeft: 0, ScrollTop: 20 }); }
ActiveDocument.SetCommentEnabled()
You can specify whether to hide the comment feature by using the SetCommentEnabled() method. The method is supported only on mobile devices.
Only JS-SDK V1.1.14 and later support this feature.
Syntax
expression.ActiveDocument.SetCommentEnabled({ Enable })expression: the document type application object.
Parameters
Property
Type
Required
Description
Enable
Boolean
Yes
Specifies whether to hide the comment feature. Valid values:
true
false
Example
async function example() { await instance.ready(); const app = instance.Application; // Set the comment feature to hidden. await app.ActiveDocument.SetCommentEnabled({ Enable: true, }); }
ActiveDocument.SetWatermark()
You can add a watermark to a document by using the SetWatermark() method.
Syntax
expression.ActiveDocument.SetWatermark({ Type, Value, FillStyle, Font, Rotate, Horizontal, Vertical })expression: the document type application object.
Parameters
Property
Type
Required
Description
Type
Number
Yes
Specifies whether to add a watermark. Valid values:
1: add a watermark.
0: no not add watermarks.
Value
String
Yes
The text in the watermark.
FillStyle
Object
No
The fill style of the watermark.
Font
Object
No
The font of the watermark.
Rotate
Number
No
The rotation angle of the watermark.
Horizontal
Number
No
Horizontal margin
Vertical
Number
No
Vertical margin
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Add a watermark to the safe document. await app.ActiveDocument.SetWatermark({ Type: 1, Value: 'WebOffice', FileStyle: 'rgba(192, 192, 192, 0.6)', Font: 'bold 20px Serif', Rotate: -45 * Math.PI / 180, Horizontal: 50, Vertical: 100, }); }
ActiveDocument.SwitchFileName()
You can specify whether to display the file name column by using the SwitchFileName() method.
Only JS-SDK V1.1.10 and later support this feature.
The file name column is available in the web layout view. The column displays the file name at the beginning of the content.
This method takes effect only in the web layout view.
Syntax
Expression. ActiveDocument.SwitchFileName(Boolean)expression: the document type application object.
Parameters
If you specify
trueforBoolean, the file name column is displayed. If you specifyfalse, the file name column is hidden.Example
async function example() { await instance.ready(); const app = instance.Application; // Switch to the web layout view. await app.ActiveDocument.SwitchTypoMode(true); // Hide the file name column. await app.ActiveDocument.SwitchFileName(false); }
ActiveDocument.SwitchTypoMode()
You can switch between the page layout view and web layout view by using the SwitchTypoMode() method.
Only JS-SDK V1.1.10 and later support this feature.
Syntax
expression.ActiveDocument.SwitchTypoMode(Boolean)expression: the document type application object.
Parameters
If you specify
trueforBoolean, you switch to web layout view. If you specifyfalse, you switch to page layout view.Return values
A
Booleanvalue oftrueindicates that the request is successful, and a value offalseindicates that the request failed.Example
async function example() { await instance.ready(); const app = instance.Application; // Switch to page layout view. await app.ActiveDocument.SwitchTypoMode(false); }
ActiveDocument.GetMissingFontList()
You can obtain a list of missing fonts by using the GetMissingFontList() method.
Syntax
expression.ActiveDocument.GetMissingFontList()expression: the document type application object.
Return values
A list of missing fonts.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; const list = await app.ActiveDocument.GetMissingFontList(); console.log('list: ', list); }
ActiveDocument.Protect({ Password })
You can enable editing restrictions by using the Protect() method.
Syntax
expression.ActiveDocument.Protect({ Password })expression: the document type application object.
Parameters
Property
Type
Required
Description
Password
String
No
The password that you specify.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Enable editing restriction. await app.ActiveDocument.Protect('test'); // Disable editing restriction. await app.ActiveDocument.Unprotect('test'); }
ActiveDocument.Unprotect({ Password })
You can disable editing restrictions by using the UnProtect() method.
Syntax
expression.ActiveDocument.Unprotect({ Password })expression: the document type application object.
Parameters
Property
Type
Required
Description
Password
String
No
The password that you specify.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Enable editing restriction. await app.ActiveDocument.Protect('test'); // Disable editing restriction. await app.ActiveDocument.Unprotect('test'); }
ActiveDocument.SetContentControlAuthority({ DefaultPermission, Permissions })
You can set a content control to read-only by using the SetContentControlAuthority() method.
Syntax
expression.ActiveDocument.SetContentControlAuthority({ DefaultPermission, Permissions })expression: the document type application object.
Parameters
Property
Type
Required
Description
DefaultPermission
String
No
The default permissions of content controls. Valid values:
read: read-only permissions.
edit: edit permissions.
Permissions
Array.<Object>
No
The list of permissions for a single content control.
Description of permissions
Property
Type
Required
Description
tag
String
Yes
The tag of the content control.
access
String
Yes
The permissions of the content control. Valid values:
read: read-only permissions.
edit: edit permissions.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Enable editing restriction. await app.ActiveDocument.Protect(); // The content controls are set to read-only and the content controls whose tag is test are set to editable. await app.ActiveDocument.SetContentControlAuthority('read', [{ tag: 'test', access: 'edit' }]); }
ActiveDocument.SetScrollBarStyle({ BackgroundColor, HoverBackgroundColor, ScrollBarWidth, BorderRadius })
You can specify the style of the scrollbar by using the SetScrollBarStyle() method.
This method takes effect only for browsers that use the webkit kernel.
Syntax
expression.ActiveDocument.SetScrollBarStyle({ BackgroundColor, HoverBackgroundColor, ScrollBarWidth, BorderRadius })expression: the document type application object.
Parameters
Specifies an object that represents a specific style.
Property
Type
Required
Description
BackgroundColor
String
No
The background color of the scrollbar.
HoverBackgroundColor
String
No
The background color of the scrollbar when it is hovered over.
ScrollBarWidth
Number
No
The width of the scrollbar. Valid values: 0 to 100.
BorderRadius
Number
No
The border radius of the scrollbar. If you specify a negative value, this parameter is invalid.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Specify the style of the scrollbar. await app.ActiveDocument.SetScrollBarStyle({ BackgroundColor: '#FFFFFF', HoverBackgroundColor: '#ffffff', ScrollBarWidth: 6, BorderRadius: 6 }); }
ActiveDocument.CustomDocumentProperties.Add()
You can create a custom document property by using the Add() method.
Only JS-SDK V1.1.10 and later support this feature.
Syntax
expression.ActiveDocument.CustomDocumentProperties.Add({ Name, Value })expression: the document type application object.
Parameters
Property
Type
Required
Description
Name
String
Yes
The name of the document.
Value
Object
No
The value of the document.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the custom document properties. const DocumentProperties = await app.ActiveDocument.DocumentProperties; // Create a new custom document property. await DocumentProperties.Add({ Name: 'Aliyun', Value: 'test_id', }) }
ActiveDocument.CustomDocumentProperties.CalcDocumentId()
You can specify a custom rule to calculate the ID of a document by using the CalcDocumen() method.
Only JS-SDK V1.1.10 and later support this feature.
Syntax
expression.ActiveDocument.CustomDocumentProperties.CalcDocumentId({ FileOId, OrganizationCode, SubDepartment, DocYear, DocumentType, SerialNumber })expression: the document type application object.
Parameters
Property
Type
Required
Description
FileOId
String
No
The OID of the document.
OrganizationCode
String
Yes
The organization code. The code can be up to 18 characters in length.
SubDepartment
String
Yes
The code of the sub-department. The code can be up to 3 characters in length.
DocYear
Number
Yes
The year when the document is issued.
DocumentType
String
Yes
The type of the document. Valid values: 01 to 0F. Default value: 01.
SerialNumber
String
Yes
The serial number. The serial number can be up to 5 characters in length.
Return values
Returns the document ID.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the custom document properties. const DocumentProperties = await app.ActiveDocument.DocumentProperties; // Calculate the custom document ID. await DocumentProperties.CalcDocumentId({ FileOId: '1.0.0', OrganizationCode: 'Aliyun_Test_Code', SubDepartment: '001', DocYear: new Date().getFullYear(), DocumentType: '01', SerialNumber: '00001' }); }
ActiveDocument.Find.Execute()
You can search for and highlight text by using the Find.Execute() method.
Syntax
expression.ActiveDocument.Find.Execute()expression: the document type application object.
Parameters
Property
Type
Required
Description
Text
String
No
The text to search.
ShowHighlight
Boolean
No
Specifies whether to highlight the search results. Valid values:
true (default value)
false
Example
async function example() { await instance.ready(); const app = instance.Application; // Search for and highlight text. app.ActiveDocument.Find.Execute('test', true); }
ActiveDocument.Find.ClearHitHighlight()
You can unhighlight search results by using the Find.ClearHitHighlight() method.
Syntax
expression.ActiveDocument.Find.ClearHitHighlight()expression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Unhighlight the search results. app.ActiveDocument.Find.ClearHitHighlight(); }
Properties
ActiveDocument.Content
You can obtain a Range object that represents the content of the document by using the Content method.
Only JS-SDK V1.1.10 and later support this feature.
Syntax
expression.ActiveDocument.Contentexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Return a Range object. const Range = await app.ActiveDocument.Content; // Obtain the content from the Range object. const text = await Range.Text; }
ActiveDocument.CustomDocumentProperties
You can obtain all custom properties of a document by using the CustomDocumentProperties method.
Only JS-SDK V1.1.10 and later support this feature.
Syntax
expression.ActiveDocument.CustomDocumentPropertiesexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the custom document properties. const CustomDocumentProperties = await app.ActiveDocument.CustomDocumentProperties; }
ActiveDocument.DocumentFields
Returns a DocumentFields collection that represents all document fields in the document. This is a read-only property.
Syntax
expression.ActiveDocument.DocumentFieldsexpression: the document type application object.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Returns a DocumentFields object. const DocumentFields = await app.ActiveDocument.DocumentFields; }
ActiveDocument.Fields
Returns a Fields collection that represents all fields in the document. This is a read-only property.
Syntax
expression.ActiveDocument.Fieldsexpression: the document type application object.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Return a Fields object. const Fields = await app.ActiveDocument.Fields; }
ActiveDocument.Hyperlinks
Returns a Hyperlinks collection that represents all hyperlinks in the document. This is a read-only property.
Syntax
expression.ActiveDocument.Hyperlinksexpression: the document type application object.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Return a Hyperlinks object. const Hyperlinks = await app.ActiveDocument.Hyperlinks; }
ActiveDocument.InlineShapes
Returns an InlineShapes collection that represents all InlineShape objects in the document. This is a read-only property.
Syntax
expression.ActiveDocument.InlineShapesexpression: the document type application object.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Returns an InlineShapes object. const InlineShapes = await app.ActiveDocument.InlineShapes; }
ActiveDocument.PageSetup
Returns a PageSetup object that is associated with the document.
Syntax
expression.ActiveDocument.PageSetupexpression: the document type application object.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Returns a PageSetup object. const PageSetup = await app.ActiveDocument.PageSetup; }
ActiveDocument.ReadOnly
You can set a document to read-only by using the ReadOnly method.
Only JS-SDK V1.1.14 and later support this feature.
Syntax
expression.ActiveDocument.ReadOnlyexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Set the document to read-only. const ReadOnly = await app.ActiveDocument.ReadOnly; }
ActiveDocument.ReadOnlyComment
Returns a value that indicates whether the document has read-only permissions and comment permissions. This is a read-only property.
Syntax
expression.ActiveDocument.ReadOnlyCommentexpression: the document type application object.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; const ReadOnlyComment = await app.ActiveDocument.ReadOnlyComment; }
ActiveDocument.SupportReadOnlyComment
Returns a value that indicates whether the document supports the read-only permissions and comment permissions. This is a read-only property.
Syntax
expression.ActiveDocument.SupportReadOnlyCommentexpression: the document type application object.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; const SupportReadOnlyComment = await app.ActiveDocument.SupportReadOnlyComment; }
ActiveDocument.Revisions
Returns a Revisions collection that represents the modifications to markups in a range or document. This is a read-only property.
Syntax
expression.ActiveDocument.Revisionsexpression: the document type application object.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Return a Revisions object. const Revisions = await app.ActiveDocument.Revisions; }
ActiveDocument.Sections
Returns a Section collection that represents all sections in the document. This is a read-only property.
Syntax
expression.ActiveDocument.Sectionsexpression: the document type application object.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Return a Sections object. const Sections = await app.ActiveDocument.Sections; }
ActiveDocument.Shapes
Returns a Shapes collection that represents all Shape objects in the document. This is a read-only property.
Syntax
expression.ActiveDocument.Shapesexpression: the document type application object.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Return a Shapes object. const Shapes = await app.ActiveDocument.Shapes; }
ActiveDocument.Tables
Returns a Table collection that represents all tables in the document. This is a read-only property.
Syntax
expression.ActiveDocument.Tablesexpression: the document type application object.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Returns a Tables object. const Tables = await app.ActiveDocument.Tables; }
ActiveDocument.TrackRevisions
You can switch the active document between the edit mode and the review mode by using the TrackRevisions method.
Only JS-SDK V1.1.10 and later support this feature.
JS-SDK V1.1.15 and later allow you to check whether the current page is in the review mode.
Syntax
expression.ActiveDocument.TrackRevisions=Booleanexpression: the document type application object.
Parameters
If you specify
truefor theBoolean, you switch the page to the edit mode. If you specifyfalse, you switch the page to the review mode.Example
Switches between the edit mode and the review mode.
async function example() { await instance.ready(); const app = instance.Application; // Switch the current document to the review mode. app.ActiveDocument.TrackRevisions = true; }Check whether the current page is in the review mode.
async function example() { await instance.ready(); const app = instance.Application; // Check whether the current page is in the review mode. const TrackRevisions = await app.ActiveDocument.TrackRevisions; console.log(TrackRevisions); }
ActiveDocument.ActiveWindows
Returns a Windows collection that represents all windows of the document. This is a read-only property.
Syntax
expression.ActiveDocument.ActiveWindowsexpression: the document type application object.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Returns a Windows object. const Windows = await app.ActiveDocument.ActiveWindows; }
ActiveDocument.Words
You can obtain a Words collection that represents all words in a document by using the Words method.
Only JS-SDK V1.1.10 and later support this feature.
Syntax
expression.ActiveDocument.Wordsexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtains all words in the document. const Words = await app.ActiveDocument.Words; }
ActiveDocument.Words.Count
You can obtain the number of words in a document by using the Count method.
Only JS-SDK V1.1.10 and later support this feature.
Syntax
expression.ActiveDocument.Words.Countexpression: the document type application object.
Return values
Property
Type
Description
wordCount
Number
The number of words.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the number of words in the document. const count = await app.ActiveDocument.Words.Count; console.log(count); }
ActiveDocument.Find
You can search for objects by using the Find method. The properties and methods of the Find object correspond to the options in the Find and Replace dialog box.
Only JS-SDK V1.1.10 and later support this feature.
Syntax
expression.ActiveDocument.Findexpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Search for an object. const Find = await app.ActiveDocument.Find; }