TX Text Control .NET Server

Javascript: TextFrameCollection.addAtFixedPositionOnPage Method

Method|Introduced in 28.0

Description

Inserts a new image which has a fixed geometrical position in the document. This position is specified through a page number and a location on this page.

Syntax

<void> TextFrameCollection.addAtFixedPositionOnPage(<Size> size, <number> pageNumber, <Point> location, <TextFrameInsertionMode> insertionMode, [<RequestTextFrameCallback> callback], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
size

The text frame's size in twips.

pageNumber

Specifies the number of a page beginning with 1 where the text frame is located.

location

Specifies the location, in twips, at which the text frame is to be inserted. This is a location relative to the top left corner either of a page or of a paragraph.

insertionMode

Specifies how the text flow is handled.

callback

Optional. The newly created text frame object is returned via this callback function.

errorCallback

Optional. Is called when the operation failed with an error.

Examples

The following example demonstrates TextFrameCollection.addAtFixedPositionOnPage in a practical document-editing workflow. It inserts a new image which has a fixed geometrical position in the document. This position is specified through a page number and a location on this page.

function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.textFrames.addAtFixedPositionOnPage(
    { width: 2880, height: 1440 },
    1,
    { x: 1440, y: 720 },
    TXTextControl.TextFrameInsertionMode.AsCharacter,
    function(textFrame) {
        if (!textFrame) {
            console.warn("No text frame was returned.");
            return;
        }
        
        console.log("add at fixed position on page result:", textFrame);
    },
    onTxError
);