Skip to main content

Signature/Image Insertion

Function Description

After integrating with business system, signatures/images can be inserted at specified positions in the document.

Notes

  1. The following uses inserting floating image as example. To insert inline image, use InlineShapes.addPicture API.
  2. addPicture only supports passing File object, need to convert image resource (such as base64) to File object in advance.

Code Examples

Example 1: Insert floating image in current selection

async function insertPicture(file, width, height, wrapType) {
const shape = await app.ActiveDocument.Shapes.addPicture(
file,
undefined,
undefined,
width,
height,
undefined,
wrapType
);
}

Example 2: Insert floating image at specified bookmark position

async function insertPicture(file, width, height, wrapType) {
const bm = await app.ActiveDocument.Bookmarks.item('bm1');
const range = await bm.range;
const shape = await app.ActiveDocument.Shapes.addPicture(
file,
undefined,
undefined,
width,
height,
range,
wrapType
);
}

Example 3: Insert floating image at specified editable area position

async function insertPicture(file, width, height, wrapType) {
const pm = await app.ActiveDocument.PermMarks.item('pm1');
const range = await pm.range;
const shape = await app.ActiveDocument.Shapes.addPicture(
file,
undefined,
undefined,
width,
height,
range,
wrapType
);
}