FoxitPDFSDKforWeb v10.0.0
Foxit PDF SDK for Web
PageEditorAddon Class Reference

Provides page edit functionality for document operations within the UIExtension. More...

Inherits UIXAddon.

Public Member Functions

 activate (type)
 Activate the page editor. More...
 
 activateTouchup ()
 Activate the touchup. More...
 
 changeTextColorByRect (options)
 Change the text color by the rectangle. More...
 
 deactivate ()
 Deactivate the page editor. Must be called after activate. More...
 
 deactivateTouchup ()
 Deactivate the touchup. Must be called after activate. More...
 
 getActiveObject ()
 
 onClick (pageIndex, point, isPDFPoint=true)
 Trigger the click event. More...
 
async setEditingObjectToolStyle (style={})
 Set the editing object tool style. More...
 
async setTextToolStyle (style={})
 Set text tool style. More...
 

Detailed Description

Provides page edit functionality for document operations within the UIExtension.

Since
9.2.0
Example of obtaining and using the PageEditor Addon:
pdfui.getAddonInstance('PageEditor').then(pageEditor => {
if (pageEditor) {
// ...
} else {
console.error("PageEditor Addon instance not found.");
}
});

Member Function Documentation

◆ activate()

PageEditorAddon::activate (   type)
inline

Activate the page editor.

Parameters
typestring - The type of the object to be edited. Supported types are: 'All', 'Text', 'Image', 'Path', 'Shading'.
Returns
Promise<void> -
Example of obtaining and using the PageEditor Addon:
pdfui.getAddonInstance('PageEditor').then(pageEditor => {
if (pageEditor) {
pageEditor.activate('Text');
} else {
console.error("PageEditor Addon instance not found.");
}
});
Since
9.2.0

◆ activateTouchup()

PageEditorAddon::activateTouchup ( )
inline

Activate the touchup.

Returns
Promise<void> -
Example of obtaining and using the PageEditor Addon:
pdfui.getAddonInstance('PageEditor').then(pageEditor => {
if (pageEditor) {
pageEditor.activateTouchup();
} else {
console.error("PageEditor Addon instance not found.");
}
});
Since
10.1.0

◆ changeTextColorByRect()

PageEditorAddon::changeTextColorByRect (   options)
inline

Change the text color by the rectangle.

Note
Usually, you need to activate the touchup function before using this API.
Parameters
optionsobject - The options.
options.pageIndexnumber - The page index.
options.rectPDFRect - Specifies page rectangle in PDF coordination system.
options.colorstring - New text color to be set. Format: 0xRRGGBB.
Returns
Promise<void> -
Example of obtaining and using the PageEditor Addon:
pdfui.getAddonInstance('PageEditor').then(async pageEditor => {
if (pageEditor) {
await pageEditor.activateTouchup();
const options = {
pageIndex: 0,
rect: {
"left": 71.86691312384474,
"top": 382.9574861367837,
"right": 645.9149722735675,
"bottom": 199.29759704251387
},
color: "0x149bff"
};
await pageEditor.changeTextColorByRect(options);
await pageEditor.deactivateTouchup();
} else {
console.error("PageEditor Addon instance not found.");
}
});
Since
10.1.0

◆ deactivate()

PageEditorAddon::deactivate ( )
inline

Deactivate the page editor. Must be called after activate.

Returns
Promise<void> -
Example of obtaining and using the PageEditor Addon:
pdfui.getAddonInstance('PageEditor').then(pageEditor => {
if (pageEditor) {
pageEditor.deactivate();
} else {
console.error("PageEditor Addon instance not found.");
}
});
Since
9.2.0

◆ deactivateTouchup()

PageEditorAddon::deactivateTouchup ( )
inline

Deactivate the touchup. Must be called after activate.

Returns
Promise<void> -
Example of obtaining and using the PageEditor Addon:
pdfui.getAddonInstance('PageEditor').then(pageEditor => {
if (pageEditor) {
pageEditor.deactivateTouchup();
} else {
console.error("PageEditor Addon instance not found.");
}
});
Since
10.1.0

◆ getActiveObject()

PageEditorAddon::getActiveObject ( )
inline

Get the active graphics object.

Note
Usually, you need to activate the page editor function before using this API. For activation and deactivation, see [activate]PageEditorAddon#activate and [deactivate]PageEditorAddon#deactivate.
Returns
Promise<PageGraphicsObject|undefined> - The active graphics object, or undefined if no active object.
Example of obtaining and using the PageEditor Addon:
pdfui.getAddonInstance('PageEditor').then(pageEditor => {
if (pageEditor) {
pageEditor.activate('Text').then(() => {
pageEditor.onClick(0, {x: 100, y: 100}, true).then(() => {
pageEditor.getActiveObject().then(activeObject => {
if (activeObject) {
activeObject.setProperties({
fontColor: '#FF00FF'
});
}
});
});
});
} else {
console.error("PageEditor Addon instance not found.");
}
});
Since
9.2.0

◆ onClick()

PageEditorAddon::onClick (   pageIndex,
  point,
  isPDFPoint = true 
)
inline

Trigger the click event.

Note
Usually, you need to activate the page editor function before using this API. For activation and deactivation, see [activate]PageEditorAddon#activate and [deactivate]PageEditorAddon#deactivate.

This function is recommended to be used in visibile pages.

Parameters
pageIndexnumber - The page index.
pointObject - The point. If this is a device point, the point should be in the PDFViewer Port coordinate system. The PDF coordinates are recommended.
point.xnumber - The x coordinate.
point.ynumber - The y coordinate.
isPDFPointboolean - Whether the point is a PDF point. Default is true.
Returns
Promise<void> -
Example of obtaining and using the PageEditor Addon:
pdfui.getAddonInstance('PageEditor').then(pageEditor => {
if (pageEditor) {
pageEditor.activate('Text').then(() => {
pageEditor.onClick(0, {x: 100, y: 100}, true);
});
} else {
console.error("PageEditor Addon instance not found.");
}
});
Since
9.2.0

◆ setEditingObjectToolStyle()

async PageEditorAddon::setEditingObjectToolStyle (   style = {})
inline

Set the editing object tool style.

Note
The Settings are valid after activate the page editor. Only include the Edit Object Tool and Add Shapes Tool.
Parameters
styleobject - JSON object which indicates text tool style.
style.editObjectBoxobject - The border style of the editing object box.
style.editObjectBox.colornumber - The color of the editing object box. Format: 0xRRGGBB.
style.editObjectBox.lineTypenumber - The line style of the editing object box. Please refer to Line_Type .
style.addShapeBoxobject - The border style of the adding shape box.
style.addShapeBox.colornumber - The color of the adding shape box. Format: 0xRRGGBB.
style.addShapeBox.lineTypenumber - The line style of the adding shape box. Please refer to Line_Type .
Returns
Boolean - true if the style is set successfully, otherwise false.
Example of obtaining and using the PageEditor Addon:
pdfui.getAddonInstance('PageEditor').then(async pageEditor => {
if (pageEditor) {
let Line_Type = UIExtension.PDFViewCtrl.PDF.constant.AdvEditor.Line_Type
let style = {
editObjectBox:{
color: 0xFFFF00,
lineType: Line_Type.thinDashedDotLine
},
addShapeBox:{
color: 0xFF00FF,
lineType: Line_Type.thickDashedDotLine
}
}
await pageEditor.setEditingObjectToolStyle(style);
} else {
console.error("PageEditor Addon instance not found.");
}
});
Since
10.0.0

◆ setTextToolStyle()

async PageEditorAddon::setTextToolStyle (   style = {})
inline

Set text tool style.

Note
The Settings are valid before activate the text tool. Only include the Edit Text Tool and Add Text Tool.
Parameters
styleobject - JSON object which indicates text tool style.
style.cursorobject - The style of cursor.
style.cursor.colornumber - The color of the cursor. Format: 0xRRGGBB.
style.cursor.lineTypenumber - The line style of the cursor. Please refer to Line_Type .
style.editTextBoxobject - The border style of edit text box.
style.editTextBox.colornumber - The color of the edit text box. Format: 0xRRGGBB.
style.editTextBox.lineTypenumber - The line style of the edit text box. Please refer to Line_Type .
style.addTextBoxobject - The border style of the added text box.
style.addTextBox.colornumber - The color of the added text box. Format: 0xRRGGBB.
style.addTextBox.lineTypenumber - The line style of the added text box. Please refer to Line_Type .
Returns
Boolean - true if the style is set successfully, otherwise false.
Example of obtaining and using the PageEditor Addon:
pdfui.getAddonInstance('PageEditor').then(async pageEditor => {
if (pageEditor) {
let Line_Type = UIExtension.PDFViewCtrl.PDF.constant.AdvEditor.Line_Type
let style = {
cursor:{
color: 0xFF0000,
lineType: Line_Type.thickDashedLine
},
editTextBox:{
color: 0xFFFF00,
lineType: Line_Type.thinDashedDotLine
},
addTextBox:{
color: 0xFF00FF,
lineType: Line_Type.thickDashedDotLine
}
}
await pageEditor.setTextToolStyle(style);
} else {
console.error("PageEditor Addon instance not found.");
}
});
Since
10.0.0

Foxit Software Corporation Logo
@2024 Foxit Software Incorporated. All rights reserved.