Sub
This topic describes the API operations related to Sub objects of PDF documents.
Sub.CurrentPageChange
Listens to a change of the current page.
Syntax
expression.Sub.CurrentPageChange = eventHandleexpression: an Application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to a change of the current page. app.Sub.CurrentPageChange = async (curryPage) => { console.log ('Switch to: ', curryPage); }; }
Sub.Swipe
Checks whether the page reaches the left or right boundary in a page swipe operation. The event triggered if it reaches the boundary. You can use this API operation to implement leftward and rightward swiping of external page tabs.
Syntax
expression.Sub.Swipe = eventHandleexpression: an Application object.
Example
//@file=base.pdf async function example() { await instance.ready(); const app = instance.Application; // Monitors whether a page reaches the left or right boundary. app.Sub.Swipe = (e) => { if (e.Direction === 'Left') { console.log('The left boundary reached'); } else if (e.Direction === 'Right') { console.log('The right boundary reached'); } }; }
Sub.Scroll
Listens to scroll events.
Only the SDK for JavaScript V1.1.10 and later support this feature.
Syntax
Expression.Sub.Scroll = eventHandleexpression: an Application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active PDF document. const pdf = await app.ActivePDF; // Listen to scroll events. app.Sub.Scroll = (e) => { console.log('Scroll', e) }; // Set the position of the scroll bar after 2,000 ms. setTimeout(async () => { await pdf.ScrollTo(100, 200) }, 2000); }
Sub.ZoomUpdated
Listens to zoom events.
Only the SDK for JavaScript V1.1.10 and later support this feature.
Syntax
expression.Sub.ZoomUpdated = eventHandleexpression: an Application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active PDF document. const pdf = await app.ActivePDF; // Listen to a zoom event. app.Sub.ZoomUpdated = (e) => { console.log('ZoomUpdated', e) }; // Set the zoom ratio after 2,000 ms. setTimeout(() => { pdf.Zoom = 150; }, 2000); }
Sub.StartPlay
Listens to playback start events.
Only the SDK for JavaScript V1.1.10 and later support this feature.
Syntax
expression.Sub.StartPlay = eventHandleexpression: an Application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active PDF document. const pdf = await app.ActivePDF; // Listen to playback start events. app.Sub.StartPlay = (e) => { console.log('StartPlay', e) }; // Enter the playback state after 2,000 ms. setTimeout(() => { pdf.PlayMode = "start"; }, 2000); }
Sub.EndPlay
Listens to playback end events.
Only the SDK for JavaScript V1.1.10 and later support this feature.
Syntax
Expression.Sub.EndPlay = eventHandleexpression: an Application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the active PDF document. const pdf = await app.ActivePDF; // Listen to playback end events. app.Sub.EndPlay = (e) => { console.log('EndPlay', e) }; // Exit the playback state after 2,000 ms. setTimeout(() => { pdf.PlayMode = false; }, 2000); }
Sub.PicSelectionChange
Listens to an image selection change.
Only the SDK for JavaScript V1.1.11 and later support this feature.
Syntax
expression.Sub.PicSelectionChange = eventHandleexpression: an Application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to selection change events. app.Sub.PicSelectionChange = (e) => { console.log('PicSelectionChange', e) }; }
Sub.TextSelectChange
Listens to a text selection change.
Only the SDK for JavaScript V1.1.12 and later support this feature.
Syntax
expression.Sub.TextSelectChange = eventHandleexpression: an Application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to a text selection change. app.Sub.TextSelectChange = (e) => { console.log('TextSelectChange', e) }; }