This topic describes how to use the advanced operations to manage presentation documents, including exporting a document as a PDF or an image file, obtaining the operator information, zooming the view to fit the window, saving a document, obtaining remarks, and playing trigger animations.
Export a document
Export a document as a PDF file or an image file.
Syntax
Expression.ActivePresentation.ExportAsFixedFormat({ RangeType, FrameSlides, FixedFormatType, ImgFormat, Dpi, Combine2LongPic, From, To, WaterMark })Expression: the document type application object.
Parameters
Parameter
Type
Required
Description
RangeType
Enum
No
The type of the slide range that you want to export. Valid values of
Enum.PpPrintRangeType:1 or ppPrintAll: all slides.
2 or ppPrintSelection: selected slides.
3 or ppPrintCurrent: the current slide.
4 or ppPrintSlideRange: a specified range of slides.
5 or ppPrintNamedSlideShow: the named slides that are specified in SlideShowName.
FrameSlides
Enum
No
Specifies whether a thin frame is placed around the border of the exported slides. Valid values of
Enum.MsoTriState:-1 or msoTrue: A thin frame is placed around the border of the exported slides.
0 or msoFalse: A thin frame is not placed around the border of the exported slides.
FixedFormatType
Enum
No
The format of the file to which the document is exported. Valid values of
Enum.PpFixedFormatType:1 or ppFixedFormatTypeXPS: XPS format. This format is not supported.
2 or ppFixedFormatTypePDF (default): PDF format. This is the default value.
3 or ppFixedFormatTypeIMG: IMG format.
ImgFormat
Enum
No
The format of the image to which the document is exported. You can set this parameter if the document is exported as an image.
Valid values of
Enum.PpExportImgFormatType:0 or ppImgTypePNG: PNG format.
1 or ppImgTypeJPG: JPG format.
2 or ppImgTypeBMP: BMP format.
3 or ppImgTypeTIF: TIF format.
Dpi
Number
No
The quality of the image to which the document is exported. You can set this parameter if the document is exported as an image. Default value: 96.
Combine2LongPic
Boolean
No
Specifies whether to export the document as a long image. You can set this parameter if the document is exported as an image. Default value: false.
From
Number
No
The start page of the range of slides that you want to export. You can set this parameter if the document is exported as an image. Default value: 0.
To
Number
No
The end page of the range of slides that you want to export. You can set this parameter if the document is exported as an image. Default value: 0.
WaterMark
Boolean
No
Specifies whether the exported file has a watermark. Default value: false.
Return value
Returns the printed
url.Parameter
Type
Description
url
string
The printed URL.
Example
The document is exported as a PDF file
async function example() { await instance.ready(); const app = instance.Application; // Export the document as a PDF file. const pdfUrl = await app.ActivePresentation.ExportAsFixedFormat(); console.log(pdfUrl); }The document is exported as an image file
async function example() { await instance.ready(); const app = instance.Application; // Export the document as an image file. const pdfUrl = await app.ActivePresentation.ExportAsFixedFormat({ FixedFormatType: app.Enum.PpFixedFormatType.ppFixedFormatTypeIMG, From: 0, To: 1, }); console.log(pdfUrl); }
Obtain the operator information
Obtain the operator information.
Syntax
Expression.ActivePresentation.GetOperatorsInfo()Expression: the document type application object.
Return value
Object object
Parameter
Type
Description
type
String
The request type.
response
Object
Details about the operator.
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.ActivePresentation.GetOperatorsInfo(); console.log(operatorsInfo); }
Zoom in or out
Configure window zoom in or out.
Syntax
Expression.ActiveWindow.View.ZoomExpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // The document window object. const activeWindow = await app.ActiveWindow; // The view object. const view = await activeWindow.View; // Obtain the zoom ratio of the window. const result = await view.Zoom; console.log(result); // Set the zoom ratio. view.Zoom = 66; }
Auto zoom to fit the window
Configure whether the view is zoomed to fit the document window every time the document window is resized.
Syntax
Expression.ActiveWindow.View.ZoomToFit = NumberExpression: the document type application object.
Specify a
numberfor this property. Valid values:-1: The view is zoomed to fit the document window every time the document window is resized.0: The view is not zoomed to fit the document window every time the document window is resized.
Example
async function example() { await instance.ready(); const app = instance.Application; // The document window object. const activeWindow = await app.ActiveWindow; // The view object. const view = await activeWindow.View; // The view is not set to zoom and fit the document window every time the document window is resized. view.ZoomToFit = 0; }
Save a document
JS-SDK V1.1.9 and later support this feature.
Save changes to the document.
Syntax
Expression.ActivePresentation.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.
Description of 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 file is not updated. You do not need to save the version.
SavedEmptyFile
The file is empty and cannot be saved. This status is returned when the file is empty after the kernel is saved.
SpaceFull
The storage space is used up.
QueneFull
Frequent file saving operations are not allowed when the file is being saved. This status is returned if 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 changes to the document. const saveResult = await app.ActivePresentation.Save(); console.log(saveResult); }
Obtain remarks
JS-SDK V1.1.15 and later support this feature.
Obtain the remarks of the current page or a specified page
Syntax
Expression.ActivePresentation.GetSlideRemark()Expression: the document type application object.
Parameters
Specify a number indicating the page number.
Parameter
Type
Required
Description
SlideIndex
NumberYes
The sequence number of the page. The default value is the sequence number of the current page.
Return value
Parameter
Type
Description
remarkList
Array
The remarks.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the remarks of the current page. const operatorsInfo = await app.ActivePresentation.GetSlideRemark(); console.log(operatorsInfo); }
Obtain the remarks of all pages
Syntax
Expression.ActivePresentation.GetRemarkList()Expression: the document type application object.
Return value
Parameter
Type
Description
remarkList
Array
The remarks.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the remarks of all pages. const operatorsInfo = await app.ActivePresentation.GetRemarkList(); console.log(operatorsInfo); }
Play trigger animations
JS-SDK V1.1.15 and later support this feature.
Syntax
Expression.ActivePresentation.PlayTriggerAnim()Expression: the document type application object.
Parameters
Parameter
Type
Required
Description
TargetShapeId
number
Yes
The ID of the trigger animation.
SlideCategory
string
Yes
The type of trigger animation.
Steps
number
No
The steps.
Example
async function example() { await instance.ready(); const app = instance.Application; // Play the trigger animation. await app.ActivePresentation.PlayTriggerAnim(TargetShapeId, SlideCategory); }