This topic describes how to obtain and set the scroll bar position, and set the play mode for a PDF document.
Scroll
Obtain the scroll bar position
Syntax
Expression.ActivePDF.Scroll
Expression: the document type application object.
Return value
Returns the scroll bar position in the {x: xx, y: xx} format.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the scroll bar position. const result = await app.ActivePDF.Scroll; console.log(result); }
Set the scroll bar position
Syntax
Expression.ActivePDF.ScrollTo(x, y)
Expression: the document type application object.
Parameters
Parameter
Type
Required
Description
x
Number
No
The x-coordinate of the scroll bar position.
y
Number
No
The y-coordinate of the scroll bar position.
Example
async function example() { await instance.ready(); const app = instance.Application; await app.ActivePDF.ScrollTo(100, 100); }
Listen to scroll events
Syntax
Expression.Sub.Scroll = eventHandle
Expression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // ActivePDF const pdf = await app.ActivePDF; // Listen to scroll events. app.Sub.Scroll = (e) => { console.log('Scroll', e) }; // Set the position of the scroll bar. setTimeout(async () => { await pdf.ScrollTo(100, 200) }, 2000); }
Play mode
Set or obtain the play mode
Syntax
Expression.ActivePDF.PlayMode
Expression: the document type application object.
Valid values:
true: starts playing.
false: stops playing.
start: plays from the first page.
active: plays from the current page.
Example
//@file=base.pdf async function example() { await instance.ready(); const app = instance.Application; const pdf = await app.ActivePDF; // Set the play mode. pdf.PlayMode = "start"; // Obtain the play mode. const mode = await pdf.PlayMode; console.log(mode); }
Start playing
Syntax
Expression.ActivePDF.StartPlay(type, DisFullscreen, HiddenMenu)
Expression: the document type application object.
Parameters
Parameter
Type
Default Value
Required
Description
type
String
active
No
The play mode.
DisFullscreen
Boolean
false
No
Specifies whether to play in full-screen mode.
HiddenMenu
Boolean
false
No
Specifies whether to hide the menu.
Example
//@file=base.pdf async function example() { await instance.ready(); const app = instance.Application; await app.ActivePDF.StartPlay("active", true, true); }
Stop playing
Syntax
Expression.ActivePDF.EndPlay()
Expression: the document type application object.
Example
//@file=base.pdf async function example() { await instance.ready(); const app = instance.Application; await app.ActivePDF.EndPlay(); }
Listen to start playing events
Syntax
Expression.Sub.StartPlay = eventHandle
Expression: the document type application object.
Example
//@file=base.pdf async function example() { await instance.ready(); const app = instance.Application; //ActivePDF const pdf = await app.ActivePDF; // Listen to start playing events. app.Sub.StartPlay = (e) => { console.log('StartPlay', e) }; // Start playing. setTimeout(() => { pdf.PlayMode = "start"; }, 2000); }
Listen to stop playing events
Syntax
Expression.Sub.EndPlay = eventHandle
Expression: the document type application object.
Example
//@file=base.pdf async function example() { await instance.ready(); const app = instance.Application; // ActivePDF const pdf = await app.ActivePDF; pdf.PlayMode = "start"; // Listen to stop playing events. app.Sub.EndPlay = (e) => { console.log('EndPlay', e) }; // Stop playing. setTimeout(() => { pdf.PlayMode = false; }, 2000); }
Set or obtain the drag mode
Syntax
Expression.ActivePDF.DragMode
Expression: the document type application object.
Valid values:
true: starts dragging.
false: stops dragging.
Example
//@file=base.pdf async function example() { await instance.ready(); const app = instance.Application; const pdf = await app.ActivePDF; // Set the drag mode. pdf.DragMode = true; // Obtain the drag mode. const mode = await pdf.DragMode; console.log(mode); }
Listen to zoom events
Syntax
Expression.Sub.ZoomUpdated = eventHandle
Expression: the document type application object.
Example
//@file=base.pdf async function example() { await instance.ready(); const app = instance.Application; // ActivePDF const pdf = await app.ActivePDF; // Listen to zoom events. app.Sub.ZoomUpdated = (e) => { console.log('ZoomUpdated', e) }; // Set the zoom ratio. setTimeout(() => { pdf.Zoom = 150; }, 2000); }