This topic describes how to obtain the operator information, switch between the single-page mode and the multi-page mode, hide the table of contents, save documents, export the document as a specific type, and obtain the page height, width, and coordinates.
Obtain the operator information
Syntax:
Expression.ActivePDF.GetOperatorsInfo()Expression: the document type application object.
Return value:
Object object
Parameter
Type
Description
type
String
The request type.
response
Object
Details about the users.
Structure of the response parameter
Parameter
Type
Description
id
String
The user ID.
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
async function example() { await instance.ready(); const app = instance.Application; // Obtain the operator information. const operatorsInfo = await app.ActivePDF.GetOperatorsInfo(); console.log(operatorsInfo); }
Switch between the single-page mode and the multi-page mode
Syntax
Expression.ActivePDF.PageMode = NumberExpression: the document type application object.
Specify a value of the number type. Specify 1 to use the single-page mode. Specify 0 to use the multi-page mode.
Example
async function example() { await instance.ready(); const app = instance.Application; // Switch between the single-page mode and the multi-page mode. app.ActivePDF.PageMode = 1; }
Show or hide the table of contents
Show or hide the table of contents.
Syntax
Expression.ActivePDF.DocumentMap = BooleanExpression: the document type application object.
Specify a value of the boolean type. Specify true to show the table of contents. Specify false to hide the table of contents.
Example
async function example() { await instance.ready(); const app = instance.Application; // Show the table of contents. app.ActivePDF.DocumentMap = true; }
Save
Save changes to a document.
Syntax
Expression.ActivePDF.Save()Expression: the document type application object.
Return value
Parameter
Type
Description
result
String
The save status.
size
Number
The size of the document. Unit: bytes.
version
Number
The version number.
The following table describes the save status.
Save status
Description
ok
The version is saved. You can view the saved version in historical versions of the document.
nochange
The document is not updated. You do not need to save the version.
SavedEmptyFile
The document is empty and cannot be saved.
This status is returned when the document is empty after the kernel is saved.
SpaceFull
The storage space is used up.
QueneFull
Frequent saving operations are not allowed when the document is being saved.
This status is returned when the saving operation queue is full on the server.
fail
Failed to save the document.
Example
async function example() { await instance.ready(); const app = instance.Application; // Save the changes to the document. const saveResult = await app.ActivePDF.Save(); console.log(saveResult); }
Export a document as an image
Syntax
Expression.ActivePDF.ExportAsFixedFormat({ FixedFormatType })Expression: the document type application object.
Parameters
Parameter
Type
Required
Description
FixedFormatType
Enum
No
The type of the exported file. You can only export a document as an image. Default value: 0.
Print
Boolean
No
Specifies whether to open the file after it is exported. Default value: false. Valid values:
false
true
ImgFormat
Enum
No
The format of the exported image. Valid values of Enum.ExportImgFormatType:
0 or ImgTypePNG (default): PNG format.
1 or ImgTypeJPG: JPG format.
2 or ImgTypeBMP: BMP format.
3 or ImgTypeTIF: TIF format.
Dpi
Number
No
The image quality. Default value: 96.
Combine2LongPic
Boolean
No
Specifies whether to export the document as a long image. Default value: false. Valid values:
false
true
RangeType
Enum
No
The export range. Valid values of Enum.RangeType.
0 or ImgTypeAll: exports all pages. This is the default value.
1 or ImgTypePage: exports a specified range.
2 or ImgTypeCurrent: exports the current page.
WaterMark
Boolean
No
Specifies whether to add watermark to the exported file. Default value: false. Valid values:
false
true
From
Boolean
No
The start page. Default value: the current page.
To
Boolean
No
The end page. Default value: the current page.
Return value
Returns the printed URL.
Parameter
Type
Description
url
string
The printed URL.
Example
async function example() { await instance.ready(); const app = instance.Application; // Export the document as an image. const imgUrl = await app.ActivePDF.ExportAsFixedFormat({ FixedFormatType: app.Enum.FixedFormatType.TypeIMG, }); console.log(imgUrl); }
Obtain the page width
Obtain the width of a specified page.
This feature is supported in JS-SDK V1.1.15 and later.
Syntax
Expression.ActivePDF.GetPageWidth(PageIndex)Expression: the document type application object.
Parameters
Parameter
Type
Required
Description
PageIndex
Number
Yes
The page number. The index starts from 1.
Return value
Returns a
numberthat represents the width of the specified page.Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the width of the page. The index starts from 1. const pageWidth = await app.ActivePDF.GetPageWidth(1); console.log(pageWidth); }
Obtain the page height
Obtain the height of a specified page.
JS-SDK V1.1.15 and later support this feature.
Syntax
Expression.ActivePDF.GetPageHeigh(PageIndex)Expression: the document type application object.
Parameters
Parameter
Type
Required
Description
PageIndex
Number
Yes
The page number. The index starts from 1.
Return value
Returns a
numberthat represents the height of the specified page.Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the height of the specified page. The index starts from 1. const pageHeight = await app.ActivePDF.GetPageHeight(1); console.log(pageHeight); }
Obtain the page coordinates
Obtain the coordinates and number of the original page by using the coordinates of a point in the window.
Syntax
Expression.ActivePDF.GetPointPageInfoByWinPoint(x, y)Expression: the document type application object.
Parameters
Parameter
Type
Required
Description
x
Number
Yes
The x-coordinate of the point in the window.
y
Number
Yes
The y-coordinate of the point in the window.
Return value
Object object
Parameter
Type
Description
inContentRange
Boolean
Indicates whether the specified coordinates are in the text body area. False indicates that the coordinates are not in the text body area, and other parameters are not returned.
pageIndex
Number
The number of the original page on which the specified coordinates are located.
x
Number
The x-coordinate on the original page that corresponds to the specified point.
y
Number
The y-coordinate on the original page that corresponds to the specified point.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the coordinates and number of the original page by using the coordinates of the point in the window. const pointPageInfo = await app.ActivePDF.GetPointPageInfoByWinPoint(500,500); console.log(pointPageInfo); }