Javascript: TextFrameCollection.addAtFixedPositionInDocument Method
Description
Creates and inserts a new text frame which has a fixed geometrical position in the document. This position is specified through a location relative to the top left corner of the complete document. All gaps between the pages must be included.
Syntax
<void> TextFrameCollection.addAtFixedPositionInDocument(<Size> size, <Point> location, <TextFrameInsertionMode> insertionMode, [<RequestTextFrameCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| size | The text frame's size in twips. |
| 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 of the complete document. All gaps between the pages must be included. |
| 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.addAtFixedPositionInDocument in a practical document-editing workflow. It creates and inserts a new text frame which has a fixed geometrical position in the document. This position is specified through a location relative to the top left corner of the complete document. All gaps between the pages must be included.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.textFrames.addAtFixedPositionInDocument(
{ width: 2880, height: 1440 },
{ 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 in document result:", textFrame);
},
onTxError
);