Processing the document text.

Version :
12.03.2024, 15:56 Uhr

Processing the document text. The current text model of the document is automatically linked to the scripts. If there is no text and no frames available, the call is meaningless. In order to use the methods, the Include of text.h is necessary:

#include "internal/text.h"

In all rules, the active text model of a script is automatically defined and is available to the script. It is not necessary to address the current text selection or its frames. The requisite calculations are taken from the scripts.

The text indices used in the scripts always refer to the current application area of a scripts, i.e. a placeholder perhaps and not to the whole text box. The index 0 does not then refer to the first character of the current text frame but rather to the first character of the caller.

In text placeholders the text model is automatically determined by the text. The text indices are defined by the start and end of the placeholder.

If the placeholder is linked with a graphic frame, no text model is available.

Object panels can contain so-called panel actions. These actions are either executable using the small round button in the upper right area of the panel or by using the program menu (Plug Ins -> Panel name >...). These scripts are usually written in cscript. The current text model is then defined if the text tool is active or if the respective frame for which the script is executed is a text frame. For more, also see gRun.

If the panel action for a graphic frame is executed, no text model is available.

Scripts can be specified as the value of XML attributes of a document. In this case, possibly a text or graphic frame belongs to the XML tag, the attribute value of which is the script, and it is this frame which displays the contents of the XML tags. If the script is executed, the XML element is automatically stated together with the script. Using this element the associated text model can be ascertained during script execution and makes the following functions available.

If an XML element is not linked to a frame but to a piece of text instead, the index positions refer automatically to this text selection; the position 0 is then the text start for the XML element, not that of the text frame.

static int available()

Is a text model at all available in the script? Position and length of the available text can be be queried with start and length.

Name Type Default Description
Return int   1 text available
Return int   0 no text available
#include "internal/text.h"
if (!textmodel::available ()) return;


priint:comet InDesign® Plug-Ins, comet_pdf
start
length
fulllength

static int start(int recalc = 0)

Start position of the document text which the script may have. Scripts usually may not process the entire text of the available text model. Thus scripts which are triggered by text placeholdes, may then of course only have that text, which belongs to the placeholder of the action. The function returns the value of the global variable gStart.

Name Type Default Description
Return int   >= 0 text available
Return int   -1 no text available
recalc int 0 For performance reasons, the start position of the placeholder is taken directly from the document when the script is started only. After that the start position is only adjusted if function calls of the script require it.

Shall I recalculate the placeholder position from the document?

0 : No, use the start position calculated by the script.

1 : Yes, recalculate placeholder position from the document. The length of the placeholder will also be recalculated.
#include "internal/text.h"
int	startPos = textmodel::start ();

recalc since v4.1 R24701

priint:comet InDesign® Plug-Ins, comet_pdf
available
length
gStart
fulllength
comet.CTextModel.getStart

static int length()

Length of the document text which the script may have. Scripts usually may not process the entire text of the available text model. Thus scripts which are triggered by text placeholdes, may then of course only have that text, which belongs to the placeholder of the action. The function returns the value of the global variable gLen. In order to ascertain the complete length of the text, the function textmodel::fulllength may be used.

Name Type Default Description
Return int   >= 0 length of the available text
Return int   -1 no text available
recalc int 0 For performance reasons, the length of the placeholder is taken directly from the document when the script is started only. After that the placolders length is only adjusted if function calls of the script require it.

Shall I recalculate the placeholder length from the document?

0 : No, use the length calculated by the script.

1 : Yes, recalculate placeholder length from the document. The start position of the placeholder and gStart will also be recalculated.
#include "internal/text.h"
int	endPos = -1;
if (textmodel::available ())
 	endPos = textmodel::start () + textmodel::length ();

recalc since v4.1 R24701

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator
available
length
gLen
fulllength
comet.CTextModel.getLength

static int get_frame(int textPos, ItemRef frameRef = 0)

Find the frame at a given text position. If the given text position is in overset, the first frame of the chain is returned in frameRef. The text model of the script is used.

Name Type Default Description
Return int   0 or ErrorCode

-1 : no frame found -2 : no textmodel
textPos int - text position (0-based). In text placeholders the position is relative to the placeholder.
frameRef ItemRef 0 allocated ItemRef for the result frame
#include "internal/text.h"

Version 2.0 R 630, 19. Mar 2008

priint:comet InDesign® Plug-Ins
get_frame_containing
comet.CTextModel.getFrame

static int get_frame_containing(
  ItemRef frameRef,
  int textPos,
  ItemRef resultRef = 0,
  int* column = 0)

Find the frame at a given text position. If the given text position is in overset, the first frame of the chain is returned in resultRef.

Using comet_pdf, an additional renderer run must be performed to determine the frame. This is a very time-consuming process!

Name Type Default Description
Return int   0 or ErrorCode

-1 : text position is in overset, resultRef contains the first frame of the chain
textPos int - text position (0-based). The value is realtiv to the text, not to any placeholder.
frameRef ItemRef - valid frame reference

0 : current script frame
resultRef ItemRef - allocated ItemRef for the result frame.
column int* 0 0-based number of column in text. comet_pdf ignores this parameter.

0 : ignore column number
#include "internal/text.h"
int main ()
{
    char 		str[2048];
    int			textPos	= 0;
    int			result	= 0;
    ItemRef		fr		= item::alloc ();
strcpy (str, "0"); if (!askstring (str, "text position", "frame @ text position", "", "", 0)) return 0; textPos = val (str);
result = textmodel::get_frame_containing (gFrame, textPos, fr); if (result == -1) showerror ("Text position %d in overset", textPos); else if (result == 0) showmessage ("Text position %d is in frame %d", textPos, item::getint (fr)); else showerror ("Fehler '%s'", serror (result));
return 0; }

Collect all placeholders of a given frame and write some information to the log. Dont forget to clear the ItemList flist. The ItemRef added to this list was NOT allocated by the funtion query_links.

#include "internal/types.h"
#include "internal/text.h"
int query_links (ItemRef frameRef) { ItemList flist = itemlist::alloc (); LinkList lli = linklist::alloc (); ItemRef fr = item::alloc (); Link li; int inOverset = 0;
itemlist::append (flist, frameRef); linklist::collect_any (lli, flist, "--list--", kFirstIgnore, kSortNo); itemlist::clear (flist); // otherwise itemlist::release will delete frameRef too! wlog ("", "# %d Placeholders found.\n", linklist::length (lli));
li = linklist::first (lli); while (li) { if (!link::isframe (li)) { inOverset = textmodel::get_frame_containing (link::frame (li), link::pos (li), fr); if (!inOverset && link::length (li) > 0) { inOverset = textmodel::get_frame_containing (link::frame (li), link::pos (li)+link::length (li), fr); }
wlog ("", "# [%d, %d]", link::pos (li), link::pos (li)+link::length (li)); wlog ("", " %d (%d)", item::getint (link::frame (li)), item::getint (fr)); if (inOverset == -1) wlog ("", " in Overset"); wlog ("", "\n"); }
li = linklist::next (lli); }
linklist::release (lli);
return 0; }
int main () { query_links (gFrame); return 0; }

Version 3.1 R2222, 9. Dez. 2010
Parameter column seit v4.0.5 R21556, 23. Okt 2017
Available for comet_pdf since v4.1.8 R28010, 25. Jan 2021

priint:comet InDesign® Plug-Ins, comet_pdf
get_frame
position_visible

static int get_placeholder(
  ItemRef frame,
  int pos,
  int* start = 0,
  int* length = 0,
  int* phID = 0,
  idtype* id = 0)

Determine the placeholder at a given text position.

Name Type Default Description
Return int   0 : Placeholder found
otherwiese : ErrorCode, no plaeholder found
frame ItemRef - Valid text frame
0 : Current script frame or frame of current text
pos int - Position of letter in text. 0-based

The character position is global, not placeholder-relative.
start int* 0 On successful return :

Start position of the placeholder found
len int* 0 On successful return :

Length in letters of the placeholder found
phID int* 0 On successful return :

ID of the placeholder found
id IDType 0 On successful return :

ID of the object to which the placeholder is linked.

The script inserts a paragraph delimiter behind the current placeholder if the placeholder directly behind it is longer than 1. In scripts for placeholders delimiters it will add the paragraph as to be the postfix of the current placeholder.

Attention : In productive applications the test on length 1 should be replaced by the check for an empty placeholder (<0x200B>)!

int main ()
{
    int 	res;
    int 	pid, s, len;
    IDType	id = idtype::alloc ();
res = textmodel::get_placeholder (gFrame, gStart+gLen, &s, &len, &pid, id);
if (res == 0 && len > 1) { textmodel::insert ("%!TT", gLen); }
return 0; }

v4.1 R24702, 5. Feb 2019 (TẾT 2019)

priint:comet InDesign® Plug-Ins

placeholder::get_value
placeholder::sget_value

static int position_visible(ItemRef frameRef, int textPos)

Determine whether a give text position is visible or hidden. The function checks the entire frsme chain of the text of the given frame.

Name Type Default Description
Return int   1 : visible
0 : hidden or error
frameRef - Valid text frame

0 : current script frame
 
textPos int - text position (0-based). The value is realtiv to the text, not to any placeholder.
#include "internal/text.h"
int main ()
{
    ItemRef		parent	= item::alloc ();
    int			tpos;
    int			visi;
if (frame::isinline (gFrame)) { frame::textframe (gFrame, parent);
tpos = frame::inlinepos (gFrame); visi = textmodel::position_visible (parent, tpos);
if (visi) wlog ("", "# Inline frame %d is visible at text position %d.\n", item::getint (gFrame), tpos); else wlog ("", "# Inline frame %d is at hidden text position %d.\n", item::getint (gFrame), tpos); }
return 0; }

Version 3.1 R2223, 22. Dez. 2010

priint:comet InDesign® Plug-Ins
get_frame_containing

static int force_redraw(ItemRef frameRef = 0, int textPos = -1)

Render the given text. Use this call vary rarely, it is very expensive. To redraw the entire document window, please use the document::force_redraw.

Using comet_pdf the function is a nop.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef 0 Valid text frame
0 : current text
textPos int kEnd Render text up to this textposition.

kEnd : end of text
#include "internal/text.h"

Version 2.0 R 634, 20. March 2008

priint:comet InDesign® Plug-Ins, comet_pdf
document::force_redraw

static int get_table(
  ItemRef frameRef,
  int textPos,
  ItemRef tableRef,
  int* left = 0,
  int* top = 0,
  int* right = 0,
  int* bottom = 0,
  int* anchor = 0,
  int* anchorLen = 0,
  int* tableStart = 0,
  int* tableLen = 0,
  int* cellStart = 0,
  int* cellEnd = 0)

Find out the table and the surounding grid area at a given text position inside a table cell.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame
0 : current text
textPos int - text position (must be inside a table cell)
tableRef Table - Allocted out variable
left, top int* 0 Left-top corner of the resulted grid area (0-based)
right, bottom int* 0 End of grid area (0-based). The values are the first column/row outside the area. For the first (single) cell of a table you will get the results [0, 0, 1, 1].
anchor, anchorLen int* 0 Anchor position and anchor length of the table inside the text
tableStart, tableLen int* 0 Text range of the tables content. Do never ever change this text range directly. Use the appropriate table methods instead!
cellStart, cellLen int* 0 Text range of the cells inside left, top, right and bottom. Cells are delimited by an internal return wich is counted here. The cell content Clara will result a length of 6 therefor.
#include "internal/text.h"

The example shows, how to change the currently selected cell in a table scripting. Some information about the table and the selected cell(s) are written to the log.

#include "internal/text.h"
#include "internal/types.h"
int main () { Table T = table::alloc (); int l, t, r, b; int anchor1, anchorLen; int text1, textLen; int cell1, cellLen; int res;
res = textmodel::get_table (0, kSelection, T,   // Optional   &l, &t, &r, &b,   &anchor1, &anchorLen,   &text1, &textLen,   &cell1, &cellLen); if (res == 0) { wlog ("", "Grid area : [%d, %d] - [%d, %d]\n", l, t, r-1, b-1); wlog ("", "\tAnchor : [%d, %d]\n", anchor1, anchor1+anchorLen); wlog ("", "\tTable text range: [%d, %d]\n", text1, text1+textLen); wlog ("", "\tCell text range: [%d, %d]\n", cell1, cell1+cellLen);
table::colorize_rows (T, t, b-t, 255, 0, 0, 50.0, "Rot"); table::colorize_cols (T, l, r-l, 0, 0, 255, 50.0, "Blau"); table::colorize (T, l, t, r, b, 0, 2500, 0, 50.0, "Grün"); } else wlog ("", "no table selected\n");
return 0; }

Version 2.0 R 634, 20. March 2008

priint:comet InDesign® Plug-Ins, comet_pdf
table::get_anchorpos

static int overset(ItemRef fm, int fullChain = -1)

Are text pieces of a text model or frame not visible? If the text has this overset a small red plus for marking will be displayed on the bottom right of the selected frames. The function can only determine the overset only of textframes or texts.

Name Type Default Description
Return int   0 : no overset or error
Return int   otherwise : text overset The value is not the number of invisible letters.
fm ItemRef 0 If no frame is specified, the current text model will be use as a test. If a frame is specified an attempt will be made to test this text.
fullChain int kFullChain Shall I check the complete text frame chain?
kFullChain : Check complete chain
0 : Check the given frame itself
#include "internal/text.h"
int 	k = textmodel::overset (fm );

Version 1.1.4
kFullChain since version 1.4 R310, 9. Feb. 2007

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator
frame::shows_textend

static int insert(
  char* str,
  int position = 0,
  int autoLoad = 1,
  int flags = 0)

Inserting text. Tagged text may also be inserted.

If text is inserted in a text placeholder, the placeholder is also applied to the new text. Inner placeholders created by w2 tags of the inserted text are lost here!. See chapter Load inner placeholders to find a workaround to load inner placeholders before.

What if inner placeholders inserted by text placeholders were not removed? The resulting nuclear fission would add new more and more placeholders on each update.

Here's a load script creating an inner placeholder:

int main ()
{
    char	tt[2000];
    int		readable;
    sprintf (tt, "%%!TTAB<w2:10, %d, 0, 0,''>ab</w2>YZ", gRecordID);
    readable = prefs::set_tags_readable (0);     textmodel::replace (tt);     prefs::set_tags_readable (readable);
    return 0; }

In the screenshot you can see how this script would work without any further action by the plugins. At the top you see the original placeholder, then the results after one up to four updates. The number of placehoders is doubled by each update (2 n + 1 - 1).

The loading of inner placeholders is only supported if placeholders are not directly created on TaggedText import. If placeholders are created directly from the TaggedText import, the inner placeholders can not be loaded. Use this settings to support loading of inner placeholders:

The above example deactivates the direct creation of sub-placeholders by using the script function prefs::set_tags_readable (0). Here is a screenshot of a loaded placeholder:

Please note the following restrictions:

In the above example, of course, it's easy to avoid the inner placeholders: Replace the placeholder by the inner placeholder.

In general, inner placeholders are used in enums where individual placeholders can be empty, and the only task of the outer placeholder is to set (or remove) the delimiters between the placeholders. In this case you can replace the outer placeholder by the inner placeholders too and set some pre- and post-fix texts to create the according delimiters.

Available only if the menu Plug-Ins -> Comet -> Read PlaceHolders from TaggedText is activated or

    prefs::set_tags_readable (1);

was executed before! More information about the so-called native import of placeholders can be found here.

Paragraphs in TaggedText are set with the tag <ParaStyle:StyleName>. Missing style names are automatically replaced by the paragraph style at the insertion point.

In addition InDesign® also expects the definition of paragraph styles at the beginning of table cells. Missing or empty paragraph styles in table cells are not automatically replaced by the paragraph style specified by table and cell styles. This can lead to considerable problems in the InDesign® document:

  1. Cells are using wrong fonts and font colors.
  2. Unfortunately, these wrong fonts in most cases are bigger than the right ones and cells will therefore get oversets. To resolve these oversets, you have to increase row heights.
  3. Cells are getting a so called local override and are marked with a + in cell styles panel.
  4. If you edit an empty cell later, this cell will get the wrong font too.
  5. Styles of following paragraph are wrong of course.

The easiest solution of this would be adding parastyles to all cells. But what if you do not know these parastyles?

The priint:priint:comet InDesign® Plug-Ins therefore offer the possibility to independently determine the current paragraph style in table cells from the cell and table style used (since v4.0.5 R18210). After setting the first paragraph style, all the remaining paragraphs are fixed in respect to the paragraphs next style until the end of the cell (since v4.0.5 R19061 and not for nested tables).

In empty table cells missing parastyles are inserted by default. To activate this for non-empty cells and/or the complete text, set the parameter flags of the import functions (textmodel::insert, textmodel::replace, ... frame::insert, ...) to one of the followng values :

As an alternative to setting the flags parameter, you can also change the trailer of the TaggedText (i.A.%!TT). A description of the valid identifiers can be found here.} For trailers that differ from the standard %! (for example %? or %%), flags are ignored.

Only important for flags 1 or 2

This methods only work with non-nested tables.

In cells with several paragraphs, ParaStyle tags (including the introductory ones behind CellStart) are mandatory. Missing ParaStyles in multi-paragraph cells may cause missing paragraph separators in the InDesign® document. To avoid conflicts with resolving missing paragraph styles outside of tables, paragraph styles in table cells, whose definitions should be automatically detected, must be marked by the keyword W2AUTODETECT (in exactly this notation). For better readability, you should use this notation in single paragraph cells too:

     <ParaStyle:W2AUTODETECT>

Available only if the menu Plug-Ins -> Comet -> Read PlaceHolders from TaggedText is activated or

    prefs::set_tags_readable (1);

was executed before! More information about the so-called native import of placeholders can be found here.

Inserting the missing paragraph styles into empty table cells unfortunately uncovered another error of InDesign®: Sometimes, but unfortunately only sometimes, InDesign® inserts an empty paragraph in table cells, although the cell content only consists of a <ParaStyle:...> without any further text. But we couldn't see any rules except that the problem not exists in merged (i.e. invisible) cells.

To solve this problem, we select all empty cells before importing them. If such a cell should contain text after the import, this text will automatically be removed from the cell.

... which brings us straight to the next problem: Surprisingly, InDesign® adds the content of invisible cells as a new paragraph to the contents of the anchor cell. Apparently the merges are done after the actual import.

The problem is that we can then no longer decide whether an empty paragraph at the beginning of the anchor cell came from a hidden cell or was an error of InDesign®. Therefor if an anchor cell is empty, the contents of its subcells will not be imported.

Generally applies : Hidden cells should not contain any content!

Mistakes in the TaggedText especially of tables can destroy documents and/or may crash InDesign®. The priint:priint:comet InDesign® Plug-Ins can therefore perform an integrity test of the table definitions in the TaggedText. The TaggedText can contain as many arbitrarily nested tables.

To enable the integrity tests, add the value 8 to the flags parameter of the functions for importing TaggedText (textmodel::insert, textmodel::replace, ..., frame::insert, ...).

Errors in the TaggedText of tables are not automatically repaired. In the case of errors in the TaggedText of tables, the entire text to be inserted is replaced by an error text that is inserted into the document in a red color.

Here, a cell is intended to merge a cell area that is larger than the area that is available below and right the cell. Or, in other words, the cell should have a larger merge range than it has available.

ERROR IN TAGGED TEXT : Maximum allowed span for body cell [r5 x c1] is 5:3 but got <CellStart:1,8

The following tests are performed by the integrity test:

You can set the auto correction flags in the text directly, see here for more information.

Available only if the menu Plug-Ins -> Comet -> Read PlaceHolders from TaggedText is activated or

    prefs::set_tags_readable (1);

was executed before! More information about the so-called native import of placeholders can be found here.

In Tags can be automatically converted to w2inlines before inserting the TaggedText.

To enable this feature, please add the value 16 to the flags parameter of the functions for importing TaggedText (textmodel::insert, textmodel::replace, ..., frame::insert, ...).

Since v4.1.6 R25777 the w2inline replacement always is done automatically. Since w2inline is a character attribute and can only be evaluated if a paragraph style is defined, paragraph styles are corrected in all non-empty table cells too. Changes to your TaggedText are not necessary.

Since v4.1.6 R25777 Inlines that are not defined using templates and do not contain an image (i.e. are empty) are given the content between öopening and closing in tag.

TaggedText may contain hyperlinks.

Here is a piece of TaggedText, with which a hyperlink to a page can be created. For better readability, line delimiters are inserted (wich are not allowed in InDesign® of course)

<Hyperlink:=
 	<HyperlinkName:My link>
 	<HyperlinkDest:.1401>
 	<HyperlinkDestKey:1401>
 	<CharStyleRef:>
 	<HyperlinkLength:15>
 	<HyperlinkStartOffset:0>
 	<Hidden:0>
 	<BrdrVisible:0>
 	<BrdrWidth:Thin>
 	<BrdrHilight:None>
 	<BrdrStyle:Solid>
 	<BrdrColor:0\,0\,0>
>
<! --Text of my link -->
<HyperlinkDestDefn:=
 	<HyperlinkDestName:.1401>
 	<HyperlinkDestKey:1401>
 	<HyperlinkDestPage:17>
 	<HyperlinkDestPageZoomType:Fixed>
 	<HyperlinkDestPageZoomFactor:1.03>
 	<Hidden:1>
>

InDesign® makes some demands on the text:

  1. HyperlinkLength must be the exact text length of the link inside the document. Please take care on Unicode letters like <0x00FC>, inlines, tables, and so on.
  2. <HyperlinkDestKey> must be a document wide unique number.
  3. <HyperlinkDest> and <HyperlinkDestName> must be document wide unique.
  4. <HyperlinkDestDefn>s be located at the and of the text. Otherwiese some link destinations may get odd.

Even the second and third demands are hard to fullfil, but InDesign® will crash immediately, if the import or the document contains non-unique keys or names.

If the the is build by cScript you may use the function hyperlink::get_next_unique_key to get the next available unique key. And for names you can use the keys with a trailing dot (.).

you may use a large enough number and pray, that the key is not used already. In externaly build text you may use a large enough number and pray, that the key is not used already. But please take care: If have the text imported once, you can't import it again - your keys are not unique anymore then.

[Experimental] The better way is to calculate keys and names directly before importing the text. To enable this feature, please add the value 32 to the flags parameter of the functions for importing TaggedText (textmodel::insert, textmodel::replace, ..., frame::insert, ...). The import will repair all keys and names then and missing names are inserted automatically in this case.

The automatic assignment of correct keys does not release you from the task, to define text-wide unique keys for the hyperlinks! Otherwise, the import can not find the requested definitions for the links.

Please note: We take care of errors in the repair of hyperlinks of course, but as a so called good will feature this is not part of the WERK II support.

Name Type Default Description
Return int   0 or ErrorCode
str String or char* - text to be inserted (may also be tagged text)
position int 0 scanner-relative insert position
>= 0 insert position
kEnd append
kSelection start of current document text selection. Selections in the text overset are unable to validate.For more info see here.
autoLoad int 1 Are placeholders to be loaded in the tagged text? Once you have assembled the current text, you can switch off the loading of placeholders.
0 do not load anymore placeholder contents
1 load placeholder contents
flags int 0 Instructions for preparing TaggedText.

0 : Off
2 : Fix parastyles of all cells
4 : Fix parastyles of complete text
8 : Check tables
16 : Replace <in> tags by <w2inline> tags, (since v4.1 R21213)
32 : Repair hyperlinks (since v4.1 R22201)

Please note:
  • For normal text, the parameter has no meaning.
  • If the option Plug-Ins -> Comet -> Read PlaceHolders from TaggedText is disabled, the flags 2, 4 and 16 do not have any meaning and are ignored.
  • In comet_pdf the flags 2 and 4 have no meaning, missing or empty paragraph styles are always calculated and used here.
  • \As of v4.1.6 R25777 the w2inline replacement always is done automatically. Since w2inline is a character attribute and can only be evaluated if a paragraph style is defined, the paragraphs will also be corrected in all non-empty table cells.} Changes to your TaggedText are not required for this.
#include "internal/text.h"
textmodel::insert (text)	// insert at start
textmodel::insert (text, 2)	// insert at position 2
textmodel::insert (text, kEnd)	// append
int main ()
{
    char		tt[256];
strcpy (tt, "%!TT"); strcat (tt, ""); strcat (tt, "laskjdh lajkdh kahljh äüö"); strcat (tt, "");
textmodel::insert (tt, kEnd); return 1; }


priint:comet InDesign® Plug-Ins, comet_pdf
frame::insert
prefs::set_logstate

static int append(
  char* str,
  int autoLoad = 1,
  int flags = 0)

Appending text. Input may also be tagged text. But do never use w2-tags inside any text placeholder script. See here for more information about placeholders in placeholders.

Name Type Default Description
Return int   0 oder Fehlercode
str String or char* - Text to be appended (can also be tagged text)
autoLoad int 1 Are placeholders to be loaded in the tagged text? Once you have assembled the current text, you can switch off the loading of placeholders.
0 do not load anymore placeholder contents
1 load placeholder contents
flags int 0 Instructions for preparing TaggedText.

0 : Off
2 : Fix parastyles of all cells
4 : Fix parastyles of complete text
8 : Check tables
16 : Replace <in> tags by <w2inline> tags, (since v4.1 R21213)
32 : Repair hyperlinks (since v4.1 R22201)

Please note:
  • For normal text, the parameter has no meaning.
  • If the option Plug-Ins -> Comet -> Read PlaceHolders from TaggedText is disabled, the flags 2, 4 and 16 do not have any meaning and are ignored.
  • In comet_pdf the flags 2 and 4 have no meaning, missing or empty paragraph styles are always calculated and used here.
  • \As of v4.1.6 R25777 the w2inline replacement always is done automatically. Since w2inline is a character attribute and can only be evaluated if a paragraph style is defined, the paragraphs will also be corrected in all non-empty table cells.} Changes to your TaggedText are not required for this.
#include "internal/text.h"
textmodel::append (text, 0) // Platzhalter nicht laden
int main ()
{
    char		tt[256];
strcpy (tt, "%!TT"); strcat (tt, ""); strcat (tt, "laskjdh lajkdh kahljh äüö"); strcat (tt, "");
textmodel::insert (tt, kEnd); return 1; }

Parameter flags since v4.0.5 R10000, 07. Feb 2016
Table check since v4.0.5 R21000

priint:comet InDesign® Plug-Ins, comet_pdf
frame::append
prefs::set_logstate

static int replace(
  char* str,
  int position= 0,
  int delete_len= -1,
  int autoLoad = 1,
  int flags = 0)

Replacing text. Tagged text may also be inserted. But do never use w2-tags inside any text placeholder script. See here for more information about placeholders in placeholders.

Name Type Default Description
Return int   0 or ErrorCode
str String or char* - text to be inserted (may also be tagged text)
position int 0 scanner-relative insert position
>= 0 insert position
kEnd append
kSelection current text selection. Selections in the text overset are unable to validate.For more info see here.
delete_len int kEnd Number of characters to be deleted
kEnd Delete to end of the text
autoLoad int int 1 Are placeholders to be loaded in the tagged text? Once you have assembled the current text, you can switch off the loading of placeholders.
0 do not load anymore placeholder contents
1 load placeholder contents
flags int 0 Instructions for preparing TaggedText.

0 : Off
2 : Fix parastyles of all cells
4 : Fix parastyles of complete text
8 : Check tables
16 : Replace <in> tags by <w2inline> tags, (since v4.1 R21213)
32 : Repair hyperlinks (since v4.1 R22201)

Please note:
  • For normal text, the parameter has no meaning.
  • If the option Plug-Ins -> Comet -> Read PlaceHolders from TaggedText is disabled, the flags 2, 4 and 16 do not have any meaning and are ignored.
  • In comet_pdf the flags 2 and 4 have no meaning, missing or empty paragraph styles are always calculated and used here.
  • \As of v4.1.6 R25777 the w2inline replacement always is done automatically. Since w2inline is a character attribute and can only be evaluated if a paragraph style is defined, the paragraphs will also be corrected in all non-empty table cells.} Changes to your TaggedText are not required for this.
#include "internal/text.h"
textmodel::replace (text)				// replace all
textmodel::replace (text, 2, kEnd)		// replace from position 2
textmodel::replace (text, 2, 3)			// replace from position 2-5
textmodel::replace (text, kEnd)			// append
textmodel::replace (text, 2, 0)			// insert at position 2
textmodel::replace (text, kSelection)	// replace current text selection

Parameter flags since v4.0.5 R10000, 07. Feb 2016
Table check since v4.0.5 R21000

priint:comet InDesign® Plug-Ins, comet_pdf
frame::replace
prefs::set_logstate
comet.CTextModel.replace

static int replace_all(
  char* str,
  int position= 0,
  int delete_len= -1,
  int autoLoad = 1,
  int flags = 0)

Replace inside the entire text. This function circumvents the protection afforded by start and length and uses the specified text position directly in the text model. Using this function may delete text placeholders and inline frames.

Name Type Default Description
Return int   0 or ErrorCode
str String or char* - text to be inserted (may also be tagged text)
position int 0 insert position
>= 0 insert position
kEnd append
kSelection current text selection. Selections in the text overset are unable to validate.For more info see here.
delete_len int kEnd Number of characters to be deleted
kEnd Delete to end of the text
autoLoad int 1 Are placeholders to be loaded in the tagged text? Once you have assembled the current text, you can switch off the loading of placeholders.
0 do not load anymore placeholder contents
1 load placeholder contents
flags int 0 Instructions for preparing TaggedText.

0 : Off
2 : Fix parastyles of all cells
4 : Fix parastyles of complete text
8 : Check tables
16 : Replace <in> tags by <w2inline> tags, (since v4.1 R21213)
32 : Repair hyperlinks (since v4.1 R22201)

Please note:
  • For normal text, the parameter has no meaning.
  • If the option Plug-Ins -> Comet -> Read PlaceHolders from TaggedText is disabled, the flags 2, 4 and 16 do not have any meaning and are ignored.
  • In comet_pdf the flags 2 and 4 have no meaning, missing or empty paragraph styles are always calculated and used here.
  • \As of v4.1.6 R25777 the w2inline replacement always is done automatically. Since w2inline is a character attribute and can only be evaluated if a paragraph style is defined, the paragraphs will also be corrected in all non-empty table cells.} Changes to your TaggedText are not required for this.
#include "internal/text.h"

Parameter flags since v4.0.5 R10000, 07. Feb 2016
Table check since v4.0.5 R21000

priint:comet InDesign® Plug-Ins, comet_pdf
frame::replace_all
prefs::set_logstate

static int image(
  char* image_path,
  int align = 5,
  float boundingBox = 0.0,
  int pathindex = -2,
  char* pathname = 0,
  int flags = 0,
  int cliptoFrame = 0,
  float tolerance = 0.0,
  float minPathSize = 0.0,
  float inset = 0.0,
  int alphaIndex = -2,
  char* alphaChannel = 0 )

Place a file as background image in a text frame. Synonymously you may use the function textmodel::place_file.

Name Type Default Description
Return int   0 or ErrorCode
image_path String or char* - Complete path to the file, which is to be inserted into the document
align int kMiddle image alignment inside the frame
boundingBox float 0.0 Image size inside its box in points.

0.0 : Proportionally scale the image to the frame, images smaller than the frame are unchanged

>0.0 : Proportionally scale the image to the given size, images smaller than the frame are unchangd

<0.0 : Proportionally scale the image to the given size, images smaller than the frame are zoomed
⇨ Photoshop clipping paths
pathindex int kIgnoreClipping 0-based index of clipping path
kIgnoreClipping : Do not change clip path.
kClipPathByName : Use name of clipping path.
kResetClipping : Do not apply any clip path.
pathname String or char* "" Name of clipping path. If index is >=0, the pathname is ignored
flags int kAllowHolesFlag How to clip the image? Values can be added.

kInvertFlagInvert the resulting path by combining with a path equal to the bounds of the image.
kUseHighResFlagForce edge detection to use the high resolution source image (potentially much slower but higher quality. Although the 72 dpi proxy does a pretty good job).
kAllowHolesFlagFor edge detection, do we remove the holes or leave them in.
kRestrictToFrameFlagFor edge detection, do we only detect edges within the visible portions of the image? That is, do we crop the image to its frame before performing edge detection?
cliptoFrame int 0 Use the bounding box of the clipping path as to be the frame size?
0 : Keep old frame size
1 : fit frame
tolerance float 0.0 A tolerance value specifying how close to the original path we must be if we smooth the path.
0.0 indicates a perfect match. Smoothing may simplify the path, reducing the number of points.
minPathSize float 0.0 subpaths smaller than the minPathSize will be deleted
inset float 0.0 how far to inset the path
alphaIndex int kIgnoreClipping Alpha channel to use

kIgnoreClipping : Do not change the alpha channel
kClipPathByName : Alpha channel given by name
kResetClipping : Do not apply any alpha channel.
If an image has more than one layer, the first alpha channel has the index 1. If there is only a background layer, the alpha channel has the index 0.
alphaChannel String or char* 0 Alpha channel to use while importing image. Ignored if alphaIndex is -2
#include "internal/text.h"
#include "internal/types.h"
err_code = textmodel::image (path [, alignment[, size]]);

pathindex, pathname, flags, cliptoFrame, tolerance, minPathSize, inset since version 16. March 2006 (P/R38)

alphaIndex, alphaChannel since version 3.1 R1840, 30. April 2010

priint:comet InDesign® Plug-Ins

static int excel_import(
  char* path,
  int pos,
  int delLength = 0)

Insert an Excel table into the text.

Name Type Default Description
Return int   0 or ErrorCode
path String or char* - Complete path to an Excel file. Alternatively Word files or images may be inserted at this point.
pos int - Insert position for the table

>= 0 : text position
> 0 : append text length
kEnd : append
kSelection : current text selection. Selections in the text overset are unable to validate.For more info see here.
delete_len int kEnd Number of characters to be deleted
kEnd Delete to end of the text
#include "internal/text.h"
err_code = textmodel::excel_import (path, pos, delLength);


priint:comet InDesign® Plug-Ins
frame::excel_import

static int excel_update(
  char* path,
  int tindex,
  int min_row = 0,
  int max_row = -1,
  int min_col = 0,
  int max_col = -1,
  int pos = -1,
  int delLength = 0)

Update a table of the text. The Excel file will be used as the basis for the update. If the new table is larger, new rows and columns will be correspondingly added. The former rows and columns will be used as the format for the newly created rows and columns. For the new rows and columns the format of the original table can still be adopted.
The target table will be specified using its 0-based index. If there is no original table, the table will be completely inserted new. In this case all the formats of the original table can be adopted.

Name Type Default Description
Return int   0 or ErrorCode
path String or char* - Complete path to an Excel file.
tindex int - 0-based table index
min_row int 0 Update starting from this row
max_row int kEnd Only update to this row
kEnd Update to the last row
min_col int 0 Update starting from this column
max_col int kEnd Only update to this column
kEnd Update to the last column
pos int kEnd If the table index does not yet exist, a new table will be created at this text position.
>= 0 Text position
> Append text length kEnd append
kSelection current text or cell selection. Selections in the text overset are unable to validate.For more info see here.
delete_len int kEnd Number of characters to be deleted
kEnd Delete to end of the text
#include "internal/text.h"
err_code = textmodel::excel_update (path, index, pos, delLength);


priint:comet InDesign® Plug-Ins
frame::excel_update

static char* get(
  char* result,
  int position = 0,
  int len = -1)

Obsolete Please use the alternative function textmodel::gettext instead of this.

#include "internal/text.h"

Version 1.1.5

priint:comet InDesign® Plug-Ins

static char* gettext(
  String str,
  int pos = 0,
  int len = -1,
  int fmt = 0,
  int showProgress = 0,
  int tmRelative = 0)

Get the text from the document. The specifications for position and length are scanner-relative. If the document text contains unicode characters, the length of the result is possibly larger than the text length in the document.

The export can be for plain text (kExportPlain) or as text with formats. Formats will be written as InDesign® TaggedText. The format of the TaggedText is independent of the settings of the export dialog and is always done with the following settings :

The function requires the following includes

#include "internal/types.h"
#include "internal/text.h"

The content of an empty placeholder isn't empty but a zero width space (<0x200B>). In the following code snippet the showmessage will never reached:

    textmodel::get (docText);
    if (strcmp (string::get (docText), "") == 0)
    {
        showmessage ("Empty");
    }


You must check the document text against the zero width space (UTF8 = E2 80 8B, Unicode = 200B) in this case :

    textmodel::get (docText);
    if (strcmp (strcmp (string::get (docText), "\xE2\x80\x8B") == 0)
    {
        showmessage ("Empty");
    }


If you use a tagged format to retreive the document text, please use the Unicode tag of the zero width space to compare :

    textmodel::get (docText, ..., kExportTT);
    if (strcmp (strcmp (string::get (docText), "<0x200B>") == 0)
    {
        showmessage ("Empty");
    }


For your convenience use strcmp with netWeight set to 1.

If the text is linked with floating frames, which are likewise to be exported, the command textmodel::store_macro can be used.

If the text contains InDesign® variables, the internal code used in the document (and not the current value) is exported on pure text formats like kExportPlain. Use the ~Plus~-Formats (available since v3.3 R2883) to replace InDesign® variables by their current values.

Name Type Default Description
Return char*   Content. The returned pointer can be used in functions which expect a char*string as parameter.

The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o char* values.

str String - Allocated string object
position int 0 Start position
>= 0 Text position
kSelection current text selection. Selections in the text overset are unable to validate.For more info see here.
len int kEnd Number of characters that are to be fetched
fmt int kExportPlain Export format

Attention: Ab v3.3 R2580 (20.07.2011) Comet placeholders are part of the normal tagged text import/export since this release. See here for more information about placeholders in tagged text.

Format specifications with the identifier Plus in the name additionally replace all automatic page numbers, paragraph names and footnote markers by their current values.

comet_pdf only supports the formats
  kExportPlain,
  kExportTT and
  kExportW2.
In all other caese kExportW2 is used.

kExportPlain,
kExportPlusPlain,
kExportPlainWithTables

Export purely unformatted text of the document. Characters greater 127 not defined in the extented ASCII set of Windows and Macintosh are coded in the format <00AD>. The export corresponds to the tag <text>. With kExportPlainWithTables also tables exported.

kExportHTML,
kExportPlusHTML,
kExportHTMLWithTables

Export purely unformatted text of the document. Characters greater 127 not defined in the extented ASCII set of Windows and Macintosh are coded in the format &#128;. Attention : The 'HTML' only applies to the type of coding the letters! With kExportHTMLWithTables also tables exported.

kExportPlainNoTypografics,
kExportPlusPlainNoTypografics,
kExportPlainWithTablesNoTypografics

Export purely unformatted text of the document. All typografic quotes are are replace to normal quotes (", '). The export corresponds to the tag <text_notypografics>. With kExportPlainWithTablesNoTypografics also tables exported.

kExportUnitext,
kExportPlusUnitext,
kExportUnitextWithTables

Export purely unformatted text of the document. All Asciis larger than 127 are replaced by a Hex coding in the format \00fc (a-f written in lower case!). The export corresponds to the tag <unitext>. With kExportUnitextWithTables also tables exported. Single quotation marks in the text are doubled in these formats!

kExportXUnitext,
kExportPlusXUnitext,
kExportXUnitext
kExportXMLUnitext,
kExportPlusXMLUnitext,
kExportXMLUnitextWithTables

Export the pure unformatted text of the document. Alle Asciis larger than 127 are replaced by a Hex coding in the format <0x00FC> (A-F written in upper case!). The XML version of the constants write this values in the form &#x00FC;. The export corresponds to the tag <xunitext> resp. <xmlunitext>. With kExportXUnitextWithTables also tables exported. Single quotation marks in the text are doubled in these formats!

kExportTagged

The text will be exported as InDesign® TaggedText with all formattings The export corresponds to the tag <taggedtext>.

kExportTT

The text will be exported as InDesign® TaggedText with all formattings. The definition of paragraph and character style will not be exported. The export corresponds to the tag <tttext>.

kExportW2

The text will be exported as InDesign® TaggedText with all the formattings. The definition of paragraph and character style will not be exported. In addition to the export via kExportTT all the textplaceholders will also be exported. This setting may not be used to export the text of a text placeholder. The export corresponds to the tag <w2text>.

kExportHTMLWithStyles

Since v4.0.5 R8400 Tje text is exported as HTML with charset utf-8. Forbidden characters in style names are escaped with format 0x00FF. The result contains the content of of the <body> tag only, CSS style definitions and surrounding tags are omitted.
The export corresponds to the tag <xhmlt>.
Format is not supported by comet_pdf!

kExportHTMLWithStylesAndCSS

Since v4.0.5 R8400 Like kExportHTMLWithStyles, but the result contains a complete HTML includung all necessary CSS style definitions.

To use more options for HTML exports please use URL[html::export_frame]{html.html#export_frame}.

kExportRTF

RTF formated output
Format is not supported by comet_pdf!

showProgress int false Is a progress bar to the displayed for the export?
tmRelative int 0 Position and length are relative to the current placeholder or to the current text model?

0 : placeholder
1 : text model
#include "internal/types.h"
#include "internal/text.h"

Get the entire text of the current text model and display it in a report.Because showmessage is restricted to texts with a maximum length of 3000, the current document text length may not be longer than 3000 characters

String	str = string::alloc ();
textmodel::gettext (str, 0, -1); showmessage (string::get (str));
string::release (str);

Show the current text text selection.

int main ()
{
    String				str	= string::alloc ();
    int 				start, len;
textmodel::selection (&start, &len); if (len > 0) textmodel::gettext (str, start, len);
showmessage ("%s", string::get (str));
return 0; }

Because gettext delivers a char* pointer to the text contained, the example above can be somewhat shortened.

String	str = string::alloc ();
showmessage (textmodel::gettext (str));
string::release (str);

With help of the keyword kExportPlainNoTypografics you can replace typographic qoutas in one step.

#include "internal/types.h"
#include "internal/text.h"
int main () { String cstr = string::alloc (); char str[500];
strcpy (str, textmodel::gettext (cstr,   0, kEnd,   kExportPlainNoTypografics));
showmessage ("1 : %s", str);
return 0; }

More work is to be done, if you try to replace only one type of quotas :

#include "internal/types.h"
int main () { String cstr = string::alloc (); char str[500];
strcpy (str, textmodel::gettext (cstr)); if (system::os () == kMacOS) { //text::replace_all (str, "\xe2", "'"); //text::replace_all (str, "\xd4", "'"); text::replace_all (str, "\xe3", "\""); text::replace_all (str, "\xd2", "\""); } showmessage (str); return 0; }

Version 1.1.5
Text fortmattings (ftm, flags, showProgress) from Version 1.2 (29 June 2005)
Parameter tmRelative since version 2.1 R668, 16. April 2008
~Plus~-formats since v3.3 R2883, 20.04.2012

priint:comet InDesign® Plug-Ins, comet_pdf (text format kExportPlain only)

comet.CTextModel.getText

static int fulllength(int includeTables = 0)

Ascertain the complete length (number of (unicode) characters) of the current text or the text of the current frame.

Name Type Default Description
Return int   0 or text length (number of (unicode) characters) without concluding 0-Byte.
includeTables int 0 0 : primary story only
1 : complete text including all table cells
#include "internal/text.h"

Version 1.1.4

priint:comet InDesign® Plug-Ins
length
available
frame::textlength
comet.CTextModel.getLength

static int store(
  int start,
  int len,
  DBC dbc,
  char* attr,
  char* table,
  long ID,
  long egositic = 0,
  char* pageItemName = 0)

Write the contents of the current text model to the database. All formattings, placeholders, tables and floating frames of the text will assumed to the database. The command is exclusively implemented for exporting to the database. For a universal application the command textmodel::store_macro can be used. For the simple export of formatted text without floating frames, the command textmodel::gettext can be used with the parameter kExportTagged or kExportTT.

Name Type Default Description
Return int   0 or ErrorCode
start int - Start position, from where the text is to be stored
kSelection Current text selection. Selections in the text overset are unable to validate.For more info see here.
>= 0 Text position. Values larger than the text length are placed at the end of the text
otherwise : Text start
len int - Length of the text which is to be stored
kEnd Copy to end of the text <=0 : Store an empty text
If start == kSelection the length specification has no meaning.
dbc DBC - Target database, see sql::dbconnection
attr String or char* - Attribute of the target table in which the result is to be written. The attribute must be of the BLOB type and may not be called TEXT.
table String or char* - Name of the target table. If the table name is empty (0 or ""), the database table pageitems will be used as the target table and the data stored in pageitems.data. In pageitems.preview a copy of the screenshot of the template will be stored.
ID int - ID in the target table
egoistic int 1 since version 1.34 R 343 From this release on parts of linked frames can exported too.

1 : Use only the given frame
0 : Be care of linked frames too
pageItemName String or char* 0 name of template. Used only if table is empty or pageitems
#include "internal/types.h"
#include "internal/text.h"

Store the current text in the database table without its first and last characters. The data set will be stored anew as required.

/*
create table w2test2
(
 	ID		number;
 	TXT		BLOB
);
*/
int main () { DBC dbc = sql::connection (); int result = 0;
if (!dbc || !textmodel::available ()) { showmessage ("Einloggen und Textauswahl setzen"); return 1; }
result = textmodel::store (   2,   textmodel::fulllength ()-4,   dbc,   "TXT", "w2test2",   3,   1); if (result == 0) showmessage ("Text gesichert"); else showmessage ("Fehler %d", result); return 0; }

Version 1.1.4
egoistic and pageItemName since version 1.4 R343, 31. May 2007

priint:comet InDesign® Plug-Ins
textmodel::restore
frame::store_text
frame::restore_text

static int restore(
  int start,
  int len,
  DBC dbc,
  char* attr,
  char* table,
  int ID,
  int autoLoad = 0,
  int* inserted = 0)

Replace the text of the current text model with a database-stored content. All formattings and placeholders for the text will be taken from the database. References used (formats, colors, ...), if not yet defined, will be automatically inserted in the document. If formats and colors are already defined, the presettings of the target document will be used.

As the template for the inserted text, the stored entries of the panel templates can also be used. The only precondition is that the corresponding templates contains exactly one text frame.

ab v3.3 R3228, 26.10.2012 ACHTUNG: Since this version, the behavior of the function was changed a little bit: Insert positions inside the current placeholder will interpret len placeholder relativ, NOT textmodel relativ. That means, in case kEnd points to the end of the plasce holder and not to the end of the text.

Name Type Default Description
Return int   0 or ErrorCode
start int - Start position, from where the existing text is to be overwritten. The position specfication is relative to the entire text and not relative to the placeholder.
kSelection current text selection. Selections in the text overset are unable to validate.For more info see here.
>= 0 Text position. Values larger than the text length will be placed at end of the text
otherwise : Text start
len int - Length of the text which is to be overwritten
kEnd Overwrite to the end of the text <=0 : Insert at start
If start == kSelection the length specification has no meaning.
dbc DBC - database, see sql::dbconnection
attr String or char* - Attribute of the target table in which the result is to be written. The attribute must be of the BLOB type and may not be called TEXT.
table String or char* - Name of the target table
ID int - ID in the target table.
frameRef ItemRef 0 0 - Replace the text un which the current selection is located or the text of the first selected frame.\br otherwise - replace the text of the specified frame
URL[autoLoad]{TaggedText.html#Auto_Load} int 0 Are placeholders which are located in the inserted text to be reloaded?
0 : Do not load placeholders
otherwise : load placeholders
inserted int* 0 How many characters were inserted in the text? The variable only has a purposeful value if the function is ended without error.
#include "internal/types.h"
#include "internal/text.h"

Replace the current text selection with the text saved by store.

int main ()
{
    int       result	= 0;
    result = frame::restore_text (
     	gFrame,
     	-2,
     	3,
     	sql::dbconnection (),
     	"TXT", "w2test2",
     	3);
    if (result != 0) showmessage ("Error %d", result);
    return 0;
}

The example shows how a panel script, with which the current document selection is replaced by the text which is stored in the template with the ID 20. The panel script will be appended to the panel template.

rem
rem Panel action for Templates
rem
begin delete from Actions where id = 802; insert into Actions (   id,   name,   classid,   typeid,   statement,   sequenceNr,   domainid ) values (   802,   'Append template as text',   8, -- classID, 8 for 'Pageitems' panel   0, -- typeID, unused for panelactions   '#include "internal/text.h"
  int main ()   {   DBC dbc = sql::dbconnection ();   int result = 0;
  if (!dbc || !textmodel::available ())   {   showmessage ("Log in and set text selection");   return 1;   }
  result = textmodel::restore (   kSelection,   0,   dbc,   "data",   "pageitems",   20,   1);   if (result != 0) showmessage ("%s", serror (result));
  return 0;   }',   1, -- sequenceNr   0 -- domainID ); end; /

Version 1.1.4
The parameters autoLoad and inserted are implemented since Version 1.1.7, January 2005, implementiert.

priint:comet InDesign® Plug-Ins
textmodel::store
frame::store_text
frame::restore_text
frame::insert_macro
textmodel::store_macro
frame::store_macro
v3.3 R3228
26. 10. 2012 parameter len is interpreted placeholder relativ (and not textmodel relativ) if \span[src]{insertion} points into the current script placeholder.

static int store_macro(
  int start,
  int len,
  int ID,
  int* macroID = 0,
  DBC dbc = 0,
  char* table = 0,
  char* data_attr = 0,
  char* prv_attr = 0)

Write the content of the current text model to the database. All formattings, placeholders, tables and floating frames of the text will be saved. For the simple export of formatted text without floating frames, the command textmodel::gettext can be used with the parameter kExportTagged or kExportTT.

To insert text stored with this function into a document, use the functions frame::insert_macro or textmodel::insert_macro.

Name Type Default Description
Return int   0 or errorr code
start int - Start position, from where the text is to be stored
kSelection current text selection. Selections in the text overset are unable to validate.For more info see here.
>= 0 Text position. Values larger than the text length will be place at the end of the text
otherwise : Text start
len int - Length of the text which is to be stored
kEnd Copy to the end of the text <=0 : Store an empty text
If start == kSelection the length specification has no meaning.
ID int - ID in the target table. The data set will be created as required.
<= 0 : Independently ascertain the next free ID
macroID int* 0 ID of the created or changed template. In case or error (return != 0) the variable received the value 0.
dbc DBC 0 target database. If this specification is empty, the current database connection will be displayed.
table String or char* 0 Name of the target table. The name is only relevant for export to databases. For export to XML folders and to SOAP server, the entries will be entered into the pageitems.xml file and the data and the preview stored in the sub-folders of the data-folder pageitems.
If the table name is empty (0 oder ""), the database table pageitems will be used as the target table and the data will be stored in pageitems.data. A screenshot of the template will be stored in pageitems.preview.
data_attr String or char* 0 The attribute is only relevant for export to databases (not for XML or SOAP) and a table name not equal to 0, "" or "pageitems" and specifies the attribute of the target table, in which the result is to be written. The attribute must be of the BLOB type and may not be called TEXT..
prv_attr String or char* 0 The attribute is only relevant for export to databases (not for XML or SOAP) and a table name not equal to 0, "" or "pageitems" and specifies the attribute of the target table, in which the screenshot of the result is to be written. The attribute must be of the BLOB type and may not be called TEXT..
useOldStyle int 1 since version 1.34 R 343 From this release on parts of linked frames are exported too. 1 : use only the home frame 0 : Be care of linked frames too
macroName String or char* 0 name of template. Used only if table is empty or pageitems
#include "internal/types.h"
#include "internal/text.h"

Store the current text selection in a new template.

int main ()
{
    int		res;
    int		macroID;
res = textmodel::store_macro (   -2, 0, // current text selection   -1, // create new template   ¯oID); // ID of the created template
if (res == 0 && macroID != 0)   showmessage ("Template %d created", macroID); else   showmessage ("Error %d", res);
return 0; }

Version 1.2.1 (11 August 2005) useOldStyle and macroName since version 1.4 R343, 31. May 2007

priint:comet InDesign® Plug-Ins
textmodel::insert_macro
textmodel::restore
frame::store_macro
frame::insert_macro

static int insert_macro(
  int start,
  int len,
  int ID,
  int autoLoad = 0,
  int* inserted_len = 0,
  DBC dbc = 0,
  char* table = 0,
  char* data_attr = 0)

Insert a text piece with frame::store_macro or textmodel::store_macro in the current document. The text will be inserted with all formattings. Missing paragraph and character styles will be created. Floating frames will be automatically imported and linked. Optionally the placeholder of the inserted text can be reloaded. All placeholders of the inserted text and all text and frame placeholders of the linked frames will be loaded.

ab v3.3 R3228, 26.10.2012 ACHTUNG: Since this version, the behavior of the function was changed a little bit: Insert positions inside the current placeholder will interpret len placeholder relativ, NOT textmodel relativ. That means, in case kEnd points to the end of the plasce holder and not to the end of the text.

Name Type Default Description
Return int   0 or ErrorCode
start int - Start position, from where the text is to be inserted
kSelection current text selection. Selections in the text overset are unable to validate.For more info see here.
>= 0 Text position. Values larger than the text length will be placed at the end of the text
otherwise : Text start
len int - Length of the text which is to be removed prior to the insert. When deleting this text, all floating frames which are linked with part of the deleted text will likewise be deleted.
kEnd Delete to the end of the text <=0 : Not an empty text
If start == kSelection the length specification has no meaning.
ID int - ID in the text template. For XML data and for SOAP the search entry must be located in the pageitems.xml file. The required import data will be retrieved from the pageitems/data/ID.indd file of the XML Data folder (XML) or is located under the ID pageitems/data/ID.indd on the SOAP server.
With databases, tables and columns are freely selectable. If nothing else is specified, pageitems.data will be automatically used.
URL[autoLoad]{TaggedText.html#Auto_Load} int 0 Are the placeholders to be reloaded in the text following the insert of the text?
0 : do not load
otherwise : load
inserted_len int* 0 How many characters were inserted in the text? The variable only has meaningful value if the function has ended without errors.
dbc DBC 0 target database. If this specification is empty, the current database connection will be used.
table String or char* 0 Name of the target table. The name is only relevant for export to databases. For export to XML folders and to SOAP server, the entries will be entered into the pageitems.xml file and the data and the preview stored in the sub-folders of the data-folder pageitems.
If the table name is empty (0 oder ""), the database table pageitems will be used as the target table and the data will be stored in pageitems.data. A screenshot of the template will be stored in pageitems.preview.
data_attr String or char* 0 The attribute is only relevant for export to databases (not for XML or SOAP) and a table name not equal to 0, "" or "pageitems" and specifies the attribute of the target table, in which the result is to be written. The attribute must be of the BLOB type and may not be called TEXT..
#include "internal/types.h"
#include "internal/text.h"

Insert a text template.

int main ()
{
    int		result;
    int		inserted;
result = textmodel::insert_macro (   -2, 0, // current text selection   23, // Text template ID   1, // Load placeholder   &inserted); // NUmber of new characters
if (result == 0)   showmessage ("%d Characters inserted", inserted); else   showmessage ("Error : %s.", serror (result));
return 0; }

Version 1.2.1 (11. August 2005)
v3.3 R3228, 26. 10. 2012 parameter len is interpreted placeholder relativ (and not textmodel relativ) if insertion points into the current script placeholder.

priint:comet InDesign® Plug-Ins
frame::insert_macro
textmodel::store_macro
frame::store_macro

static int floating(
  ItemRef frame,
  int pos,
  int align,
  float alignOffset,
  int linePos,
  float lineOffset,
  int flag = 1)

DEPRECATED! Please use frame::inline_, frame::inline_above, frame::anchor and frame::get_anchor instead.

Name Type Default Description
Return int   -1199
#include "internal/text.h"

Please use frame::inline_, frame::inline_above, frame::anchor and frame::get_anchor instead.

static int hasfloating(int pos)

DEPRECATED! Please use frame::isinline and frame::get_anchor instead.

Name Type Default Description
Return int   0
#include "internal/text.h"

Please use frame::isinline and frame::get_anchor instead.

static int selection(
  int* selStart,
  int* selLen = 0,
  ItemRef textFrame = 0,
  ItemList frames = 0,
  Table table = 0,
  int* leftCol = 0,
  int* topRow = 0,
  int* rightCol = 0,
  int* bottomRow = 0)

The function supplies a description of the selection of the current document. The selection of several table cells in currently not supported.

Name Type Default Description
Return int   0 or ErrorCode
selStart int* - Start of the text selection. If no text selection is set or found, the value on return is kEnd.
selLen int* 0 Length of the text selection. If no text selection is set or found, the value on return is 0.
textFrame Item 0 Frame of the text selection. If no text selection is set, the content of the variable is undefined (item::defined). The variable may be 0 but if it contains a value it must be allocated (item::alloc).
frames ItemList 0 List of the selected frames. If a text selection is set, the first (and only) element of this list is equal to textFrame. The variable may be but if it contains a value this must also be allocated (itemlist::alloc).
table Table 0 Table in which the text selection is located. If no table text is selected, the value of the variable is undefined (table::defined). The variable may be 0 but if it contains a value it must also be allocated (table::alloc).
leftCol int 0 Column number (0-based) of the table text selection. If no table text is selected, the value is equal to -1.
topRow int 0 Row number (0-based) of the table text selection. If no table text is selected, the value is equal to -1.
rightCol int 0 First not selected column (or -1 if the selection does not touch a table)
bottomRow int 0 First not selected row (or -1 if the selection does not touch a table)
#include "internal/types.h"
#include "internal/text.h"

Show the current document text selection.

int main ()
{
    String			str	= string::alloc ();
    int 			start, len;
textmodel::selection (&start, &len); if (len > 0) textmodel::gettext (str, start, len);
showmessage ("%s", string::get (str));
return 0; }

Description of the current document selection. (by Martin Lucke)

int main ()
{
    int			start, len;
    ItemRef		textFrame	= item::alloc ();
    ItemList	frames		= itemlist::alloc ();
    Table		tb			= table::alloc ();
    int			l, t, r, b;
if (textmodel::selection (   &start,   &len,   textFrame,   frames,   tb,   &l, &t, &r, &b) == 0) { char m[1000];
if (item::defined (textFrame)) { if (table::defined (tb))   showmessage ("Table text: %d-%d, Zelle %d, %d",   start, start+len, l, t); else   showmessage ("Text selection : %d-%d",   start, start+len); } else { showmessage ("%d selected frames",   itemlist::length (frames)); } } else { showmessage ("No selection in the document"); }
item::release (textFrame); itemlist::release (frames); table::release (tb);
return 0; }

Get the currently selected placeholder.

#include "internal/types.h" 
#include "internal/text.h"
int main () { ItemRef txtframe = item::alloc (); LinkList lli = linklist::alloc (1); // Objekt-Liste Link lk; int start, len, re;
textmodel::selection (&start, &len);
if(start >= 0) { re = textmodel::get_frame(start, txtframe); if (re >= 0) { linklist::text_collect(lli, txtframe, start, 1); if (linklist::length(lli)) { lk = linklist::first(lli); showmessage("Platzhalter gefunden!\n"); } else showerror("Sie haben keinen Paltzhalter ausgewählt!"); } else showerror( serror (re)); } else showerror("Sie haben keinen Text ausgewählt!"); linklist::release(lli); item::release(txtframe);
return 0; }

The parameters textFrame are new since Version 1.2 (21 July 2005)

priint:comet InDesign® Plug-Ins

static int clear_placeholders(
  int startPos,
  int len = -1,
  ItemRef frameRef = 0)

Hide placeholders from the text.

Name Type Default Description
Return int   0 or ErrorCode
startPos int - start position
kSelection : start of current text selection. Selections in the text overset are unable to validate.For more info see here.
len int kEnd length

kEnd end of text
kTotalEnd end of text incl. all table text
frameRef ItemRef 0 Textframe of textmodel

0 : current script frame
#include "internal/text.h"

Hide all placeholders from a part of a table (row 5 of table with einer 4 columns).

#include "internal/table.h"
#include "internal/text.h"
int main () { Table T = table::alloc (); int err; int t1, tmp, t2;
if (!T) return 0; if (table::get (T, 0, 0) != 0) { showmessage ("no table found"); table::release (T); return 0; }
table::get_textpos (T, 0, 4, &t1, &tmp); table::get_textpos (T, 3, 4, &tmp, &t2); t2 = tmp+t2; textmodel::clear_placeholders (t1, t2-t1);
return 0; }

Version 1.3.3 (P/R 56)
frameRef since v3.3 R3084, 17.07.2012

priint:comet InDesign® Plug-Ins

static int get_linenr(
  ItemRef frameRef,
  int textPos,
  int* lineStart = 0,
  int* lineLen = 0,
  int* endsWithHyphen = 0,
  int* lineStart_prev = 0,
  int* lineLen_prev = 0,
  int* endsWithHyphen_prev = 0)

Get the line number of a position in a text. Automatic line breaks are not counted. That means, on the other hand, the position around an automatic line break isn't unique (Do we mean the old or the new line?). get_linenr always uses the new line. To get the values of the old line, use the ~_prev parameters of the call.

Name Type Default Description
Return int   1-based line number or 0 in case of same erros
frameRef ItemRef 0 valid frame reference or 0
0 : use textmodel of script
textPos int 0 0-based Text position of line to be determined. Text positions within a table cell calculate the line number within the table cell. If the text does not contain the text position, the function returns 0. Text position in the text overset are unable to validate.
kSelection : Start of current text selection.For more info see here.
lineStart int* 0 line start position
lineLen int* 0 length of line in bytes
endsWithHyphen int* 0 does this line end with a hyphen (-)?
0 : no
1 : yes
lineStart_prev int* 0 >= 0 : line start of previous line

0 : no automatic line break at position textPos
lineLen_prev int* 0 > 0 : length of automatically broken previous line

-1 : no automatic line break at position textPos
endsWithHyphen_prev int* 0 Does the previous line end with a hyphenation (-)?
0 : no
1 : yes
#include "internal/text.h"

Find out the line holding the text cursor

#include "internal/text.h"
int main () { int a, b, h, b1; int lnr = textmodel::get_linenr (0, kSelection, &a, &b, &h, 0, &b1, 0);
if (b1 >= 0) { "small">showmessage ("Zeile %d : %d - %d\nUmbruch : Ja\nTrenner : %d", lnr, a, a+b, h); } else { "small">showmessage ("Zeile %d : %d - %d\nUmbruch : Nein\nTrenner : %d", lnr, a, a+b, h); }
return 0; }

In einer Schleife werden alle Zeilen eines Textes erfragt. Achten Sie darauf, die Anweisung x = func in der while-Schleife in Klammern zu setzen. Sonst wird die Zuweisung als boolscher Ausdruck gewertet, der immer wahr ist und damit auch > 0, also eine Endlosschleife produziert.

int main ()
{
    int		lineNr, lineLen, hyphend;
    int		lineStart = 0;
while ((lineNr = textmodel::get_linenr (0,   lineStart, &lineStart, &lineLen, &hyphend)) > 0) { showmessage ("Zeile %d : %d - %d",   lineNr, lineStart, lineStart+lineLen); lineStart += lineLen; }
return 0; }

Zähle die automatischen Zeilenumrüche eines Textes.

int main ()
{
    int 	l;
    int 	a1 		= 0, b1, b2;
    int 	aum		= 0;
while (textmodel::get_linenr (0, a1, &a1, &b1, 0, 0, &b2, 0)) { if (b2 >= 0) aum = aum+1; a1 = a1+b1; }
showmessage ("Automatische Zeilenumbrüche : %d", aum);
return 0; }

Alle Zeilenumbrüche, die auf "* " enden, sollen durch ein Softreturn ersetzt werden. Endet ein Absatz (normal oder mit Softreturn) auf "* ", soll nur das "* " entfernt werden.

int main ()
{
    int     	lineNr, lineLen, hyphend;
    int     	lineStart 	= 0;
    int     	chkPos;
    String  	str     	= string::alloc ();
    char	*	tmp;
while ((lineNr = textmodel::get_linenr (   0, lineStart,   &lineStart, &lineLen, &hyphend)) > 0) { if (lineLen > 2 && !hyphend) { chkPos = lineStart+lineLen-3;
textmodel::gettext (str, chkPos, 3); tmp = string::get (str);
if (tmp[1] == '*' && tmp [2] == ' ') { // Zeilenumbruch textmodel::replace_all ("\n", chkPos+1, 2, 0); lineLen = lineLen - 1; } else if (strcmp (tmp, "* \r") == 0 // Absatzende   || strcmp (tmp, "* \n") == 0)// Softreturn { textmodel::replace_all ("", chkPos, 2, 0); lineLen = lineLen - 2; } }
// next line lineStart += lineLen; } return 0; }

Version 1.3.4 (P/R 94)

priint:comet InDesign® Plug-Ins
coordinates

static int coordinates(
  ItemRef frameRef,
  int textPos,
  float* x = 0,
  float* y = 0,
  float* lineHeight = 0)

Determine the coordinates of a text character. The left side of the drawing frame and the position of the base line of the character are returned as text coordinates. The information is given in points relative to the upper left corner of the text frame. The characters 'a' and 'q' have the same y-position if they are on the same line. If the text position is not in the visible frame area, the character position cannot be calculated. The function then returns the character position (0.0, 0.0).

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef 0 valid frame reference or 0
0 : use textmodel of script
textPos int 0 Text position

kEnd : End of text
kSelection : start of current text selection.

Selections in the text overset are unable to validate. For more info see here.
x float* 0 left position of character frame relative to the text frame in points
y float* 0 line position of character relative to the text frame in points
lineHeight float* 0 line height in points
#include "internal/text.h"

int main () { float x, y, lh;
textmodel::coordinates (0, 1585, &x, &y, &lh); showmessage ("%f X %f, LineHeight = %f", x, y, lh);
return 0; }

Version 1.3.4 (P/R 122)

priint:comet InDesign® Plug-Ins
get_linenr

static int initialchar(
  ItemRef frameRef,
  int textPos,
  int capLines = 0,
  int capChars = 0)

Changing cap chars of a paragraph.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef 0 valid frame reference or 0
0 : use textmodel of script
textPos int 0 Text position. The position must not be the paragraph start.
kSelection :current text selection. Selections in the text overset are unable to validate.For more info see here.
capLines int 0 Height of cap chars in lines
capChars int 0 Number of cap chars
#include "internal/text.h"

Keine Initialen am Textanfang

int main ()
{
    textmodel::initialchar (gFrame, 0, 1, 1);
return 0; }

Version 1.3.4 (P/R 94)

priint:comet InDesign® Plug-Ins
get_initials
get_initiallines

static int get_initials(ItemRef frameRef, int textPos = 0)

Number of initial characters of a paragraph.

Name Type Default Description
Return int   Number of initial characters of a paragraph.?
frameRef ItemRef 0 valid frame reference or 0
0 : use textmodel of script
textPos int 0 Text position. The position must not be the paragraph start.
kSelection :current text selection. Selections in the text overset are unable to validate.For more info see here.
#include "internal/text.h"

Make bigger and more initials

int main ()
{
    int		l = textmodel::get_initiallines (gFrame, 0);
    int		c = textmodel::get_initials (gFrame, 0);
textmodel::initialchar (gFrame, 0, l+1, c+1);
return 0; }

Version 1.3.4 (P/R 94)

priint:comet InDesign® Plug-Ins
initialchar
get_initiallines

static float get_fontsize(
  ItemRef frameRef,
  int textPos = 0,
  int* attrLen = 0)

Textsize of given text position.

Name Type Default Description
Return float   Size of text in points
-1.0 : On Error
frameRef ItemRef - Valid text frame reference
0 : use textmodel of script
textPos int 0 0-based text position
attrLen int* 0 On success it contains the number of bytes using the same font size

comet_pdf stopps calculation at least at the end of the paragraph
#include "internal/text.h"

Version 1.4.2 R581, 23. Jan. 2008

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator
get_font
comet.CTextModel.getFontSize

static int set_fontsize(
  ItemRef frameRef,
  int start,
  int len,
  float fontSize)

Set the font size.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - text frame reference

0 : current script frame
start, len int, int -, - text range placeholder relative). Use use_global_index for textmodel relative indexing.
fontSize float - Size in points
#include "internal/text.h"

v3.3.1 R3228, 18.10.2012

priint:comet InDesign® Plug-Ins, Illustrator
get_fontsize
get_font
set_font
use_global_index
comet.CTextModel.setFontSize

static int get_font(
  ItemRef frameRef,
  int textPos = 0,
  char* fontFamily = 0,
  char* fontStyle = 0,
  int* attrLen = 0)

Font and font style at a given text position.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame reference
0 : Use text model of script
textPos int 0 Text position (0 based)
fontFamily String or char* 0 Font name
fontStyle String or char* 0 Font style (Bold, Italic, ...)
attrLen int* 0 Length of text with same font and and style

comet_pdf stops calculation at least at the end of the paragraph
#include "internal/text.h"

Write all font names of the current text to the logfile.

int main ()
{
    int 		i	 	= 0;
    char		fn 		[512];
    char		style 	[512];
    int			len;
while (textmodel::get_font (0, i, fn, style, &len) == 0) { wlog ("", "[%d, %d] : %s-%s\n", i, i+len, fn, style); i = i + len; }
return 0; }

Version 3.1 R2140, 29.09.2010

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator
get_fontsize
comet.CTextModel.getFont

static int set_font(
  ItemRef frameRef,
  int start,
  int len,
  char* fontname,
  char* fontface = 0)

Set the font size.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - text frame reference

0 : current script frame
start, len int, int -, - text range (placeholder relative). Use use_global_index for textmodel relative indexing.
fontname String or char* - Name of available font (for instance "Courier")
fontface String or char* 0 According font face (for instance "Oblique")
#include "internal/text.h"

v3.3.1 R3228, 18.10.2012

priint:comet InDesign® Plug-Ins, Illustrator
get_font
get_fontsize
set_fontsize
use_global_index
comet.CTextModel.setFont

static int get_initiallines(ItemRef frameRef, int textPos)

Get the height of the initial cap.

Name Type Default Description
Return int   Height of paragraph cap in lines
frameRef ItemRef 0 valid frame reference or 0
0 : use textmodel of script
textPos int 0 Text position. The position must not be the paragraph start.
kSelection :current text selection. Selections in the text overset are unable to validate.For more info see here.
#include "internal/text.h"

Version 1.3.4 (P/R 94)

priint:comet InDesign® Plug-Ins
initialchar
get_initials

static int set_attr(
  ItemRef frameRef,
  int start,
  int len,
  int attribute,
  ...)

Change text attributes. Using this function you can change nearly all text attributes supported by InDesign®. See here to learn more. The functuion needs the Include

#include "internal/textattributes.h" // Text attribute bosses

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame or 0

0 : Current script frame
start int - Text position

kSelection : Current text selection
len int - Number of letters. Unused if start = kSelection.

kEnd : End of text
attribute int - Attribute to change, see here
... abhängig von attribute - Value of attribute, see here. Wrong data types of parameters may crash InDesign®.
#include "internal/text.h"
#include "internal/textattributes.h"

v4.0.5 R13700, 16. Sep 2010

priint:comet InDesign® Plug-Ins
get_attr
Description of supported attributes

static int get_attr(
  ItemRef frameRef,
  int start,
  int* len,
  int attribute,
  ...)

Get text attributes. Using this function you can ask for nearly all text attributes supported by InDesign®. See here to learn more. The functuion needs the Include

#include "internal/textattributes.h" // Text attribute bosses

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame or 0

0 : Current script frame
start int - Text position

kSelection : Current text selection
len int* - Number of letter with the same attribute value.

0 : ignore
attribute int - Attribute to ask for? see here
... abhängig von attribute - Value of attribute, see here. Wrong data types of parameters may crash InDesign®.
#include "internal/text.h"
#include "internal/textattributes.h"

v4.0.5 R13700, 16. Sep 2010

priint:comet InDesign® Plug-Ins
set_attr
Description of supported attributes

static int get_para_listtype(ItemRef frameRef, int textPos)

Get the list type of an paragraph.

Name Type Default Description
Return int   List type of paragraph containing the given text position or -1 in case of an error.

0 : None
1 : Bulleted list
2 : Numbered list
frameRef ItemRef 0 valid frame reference or 0
0 : use textmodel of script
textPos int 0 Text position. The position must not be the paragraph start.
kSelection :current text selection. Selections in the text overset are unable to validate.For more info see here.
#include "internal/text.h"

Version 3.2 R2220, 5. Dec. 2010

priint:comet InDesign® Plug-Ins
comet.CTextModel.getListType

static int get_color(
  ItemRef frameRef,
  int whatColor,
  int pos,
  int* length,
  char* colName = 0,
  int* colSpace = 0,
  float* c1 = 0,
  float* c2 = 0,
  float* c3 = 0,
  float* c4 = 0,
  float* tint = 0,
  int* isProcessColor = 0)

Get the color of a text position

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame
0 : current text
whatColor int - What kind of color are interested in?

0 : text
1 : stroke
2 : underline
3 : underline gap
4 : strike through
5 : strike through gap
6 : Paragraph border shading
pos int - 0-based text position
length int* 0 (output) last position of same color
colName String or char* 0 Name of color
0 : ignore
otherwise : allocated string
colSpace int* 0 color space
0 : ignore
otherwise :
  kRGB   kCMYK   kLab
c1, c2, c3, c4 float* 0 color values
0 : ignore
otherwise :
  r, g, b on kRGB (0.0 - 255.0)
  c, m, y, k on kCMYK (0.0 - 1.0)
  l, a, b on kLab (0.0 - 100.0 And -128.0-127.0)
tint float* 0 tint of color
0 : ignore
otherwise : 0.0 - 100.0
isProcessColor int* 0 (output)

1 : process color
0 : spot color
#include "internal/text.h"
#include "internal/types.h"

Get all text colors in a loop.

#include "internal/types.h"
#include "internal/text.h"
int main () { char colName [256]; int colorClass, colSpace; float c1, c2, c3, c4, tint; int start = 0; int isProcess; int len;
for (colorClass = 0; colorClass < 6; colorClass++) { if (colorClass == 0) wlog ("", "Font color\n"); else if (colorClass == 1) wlog ("", "Stroke color\n"); else if (colorClass == 2) wlog ("", "Underline color\n"); else if (colorClass == 3) wlog ("", "Underline gap color\n"); else if (colorClass == 4) wlog ("", "Strike through color\n"); else if (colorClass == 5) wlog ("", "Strike through gap color\n");
start = 0; while (textmodel::get_color (0, colorClass, start,   &len,   colName,   &colSpace, &c1, &c2, &c3, &c4,   &tint,   &isProcess) == 0) { wlog ("", "\t[%d - %d]\t: ", start, start+len); if (colSpace == -1) wlog ("", "Property not used"); else { if (isProcess) wlog ("", "Process-"); else wlog ("", "Spot-"); }
if (colSpace == kRGB) { wlog ("", "RGB = (%d %d %d)", toint (c1), toint (c2), toint (c3)); } else if (colSpace == kCMYK) { wlog ("", "CMYK = (%.2f %.2f %.2f %.2f)", c1, c2, c3, c4); } else if (colSpace == kLab) { wlog ("", "Lab = (%.2f %d %d)" , c1, toint (c2), toint (c3)); } else if (colSpace >= 0) { wlog ("", "COLSPACE %d = (%.2f %.2f %.2f %.2f)" , colSpace, c1, c2, c3, c4); }
if (*colName) wlog ("", " Swatch '%s', Tint %.2f%%", colName, tint); wlog ("", "\n");
start = start + len; } }
return 0; }

Version 2.1 R1120, 15. January 2009

priint:comet InDesign® Plug-Ins
frame::get_color
comet.CTextModel.getColor

static int insert_products(
  ItemRef frameRef = 0,
  int position = 0,
  int delete_len = -1,
  char* statement = "watched",
  int preScript = kNoRule,
  int flags = 0,
  int defaultPageitem = 0,
  char* errmess = 0,
  int purgeSequence = 0,
  char* sequName = "",
  char* prefix = "",
  char* postfix = "")

Insert products into a text. The function is the text based opposite to document::build_products. The templates of a product can inserted as inline frames or (if a frame is a text frame) as text. You can define this behavior using the panel Frame rules on each of the templates frames.

The function is a variant of product building and can therefore not be called inside another building process like productlist::establish.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef 0 valid text frame or 0
0 : use the scripts textmodel
position int 0 frameRef = 0 : script relative insert index
frameRef != 0 : text model relative insert point

>= 0 insert position
kEnd append
kSelection current text selection. Selections in the text overset are unable to validate.For more info see here.
delete_len int kEnd number of characters to delete before inserting
kEnd delete until end of text

Ignored if position = kSelection.
statement String or char* "watched" Select the objects to be inserted, see here.
preScript int kNoRule ID of pre script. The script is executed after selecting the objects using statement., You may use this script to change the list of objects, see product::set, product::clone and productlist.

kNoRule - no prparation needed
otherwise, the id of the action, see here.
flags int 0 Import control, bitfield of the following values, for instance kCheckIfNotExists + kPreferDefaultPageItem

kCheckIfNotExists : Check whether the object is already inserted somewhere in the document (expensive!) kPreferDefaultPageItem : use the template defaultPageitem rather then the templates given in den objects itself.

kSuppressAutoExtent : since version 1.4 R320 On text overflow, a new page with a linked text frame is created automatically. You can suppress this behavior by setting this flag

kInsertTextBeforeExeptFirst : since version 1.4 R1180 Suppress prefix on first product.

kInsertTextAfterExeptLast : since version 1.4 R1180 Suppress postfix on last product.

kExpandGroups : since Version 1.4 R1180If the page item consists of a group, the containing frames are used for import.

kAutoDetectType : since Version 1.4 R1180 The plug-in checks for the frame type itself. If the frame is a text frame, its text content is inserted. Otherwise the frame is inserted as an inline. Ignorable frames of a template are not inserted.

kShowErrors : Invoke an error dialog automatically in case of some errors
defaultPageitem int 0 Use this template, if a product has no template defined. If the flag kPreferDefaultPageItem is set, this template is used for all products.
errmess String or char* 0 If not 0, the variable contains an error description (if any errors occur)
purgeSequence int 0 Import every object using an own sequence.

0 - Use one sequecence for all objects. Users can undo the import by one Undo. Bigger imports may cause InDesign® to invoke a warning, that the action is too big for one Undo. 1 - Use purged sequences for every object
sequName String oder char* "Building %d. product" Name of a single sequence if purgeSequence is set.
prefix String oder char* "" Insert this text before every non empty product to be imported. The prefix can be any unformated, InDesign® tagged or %!TT text. To insert an end of paragraph you may use <para> as shortcut for %!TT<ParaStyle:><nl:>.

<para> : New paragraph
postfix String oder char* "" Insert this text after every product imported. The prefix can be any unformated, InDesign® tagged or %!TT text. To insert an end of paragraph you may use <para> as shortcut for %!TT<ParaStyle:><nl:>.

<para> : End of paragraph
#include "internal/text.h"
#include "internal/types.h"
#include "internal/products.h"

Version 1.4 (R 228), 23. Oktober 2006
prefix, postfix since v1.4.1 R405, 4. Juli 2007

priint:comet InDesign® Plug-Ins
document::build_products

static int insert_list(
  ItemRef frameRef,
  int position,
  int delete_len,
  ProductList pl,
  int preScript = kNoRule,
  int flags = 0,
  int defaultPageitem = 0,
  char* errmess = 0,
  int purgeSequence = 0,
  char* sequName = "",
  char* prefix = "",
  char* postfix = "")

Like insert_products, but with a ProductList instaed of the selector statement.

The function is a variant of product building and can not called inside another building process like produktlist::establish therefor.

Name Type Default Description
pl ProductList - List of products to be inserted
... ... - see insert_products
#include "internal/text.h"
#include "internal/types.h"
#include "internal/products.h"

Insert some products at the current documents insertion point.

#include "internal/products.h"
int append_product (ProductList li, int id1, int id2, int id3, int pi) { Product p;
if (!li) return 1;
p = product::alloc (); product::set (p, kID, id1); product::set (p, kID2, id2); product::set (p, kID3, id3); product::set (p, kPageitemid, pi);
productlist::append (li, p, 1);
return 0; }
int main () { ProductList li = productlist::alloc ();
append_product (li, 100, 10, 0, 2); append_product (li, 300, 10, 0, 2); append_product (li, 400, 10, 0, 12); append_product (li, 500, 10, 0, 2);
textmodel::insert_list (0, -2, 0, li);
return 0; }

Version 1.4.2, R527, 13. Dec. 2007

priint:comet InDesign® Plug-Ins

static int vertical_justification(
  ItemRef frameRef,
  int pos,
  int justy,
  float maxParaSpace = 0.0)

Set the verticale justification and the paragraph space limit of a text frame

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - valid text frame
0 : Use the current textmodel. In case of chained frames, the second parameter verfies the frame.
pos int - text position to verify the frame in case of chained text frames and frameRef = 0

Using comet_pdf the parameter is ignored and the first frame of the chain is used always.
justy int - vertical justification
0 : top
1 : center
2 : bottom
3 : justify not supported by comet_pdf
maxParaSpace float 0.0 Paragraph space limit in points. If paramaeter is missing, this value is untouched in the frame.

This value is ignored by comet_pdf.
#include "internal/text.h"
#include "internal/types.h"
#include "internal/products.h"

Version 1.4 (R 336), 19. April 2007

priint:comet InDesign® Plug-Ins, comet_pdf

static int get_insets(
  ItemRef frameRef,
  int pos,
  float* l,
  float* t,
  float* r,
  float* b)

Set insets of a text frame

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - valid text frame
0 : Use the current textmodel. In case of chained frames, the second parameter verfies the frame.
pos int - text position to verify the frame in case of chained text frames and frameRef = 0

Under comet_pdf the first frame of chain is used always.
l, t, r, b float* - On successfull return the insets in points (left, top, right, bottom)

0 : Ignore this value
#include "internal/text.h"

Version 4.1.6 R25445, 9. Juli 2019

priint:comet InDesign® Plug-Ins, comet_pdf
set_insets

static int set_insets(
  ItemRef frameRef,
  int pos,
  float l,
  float t,
  float r,
  float b,
  float textIndest = 0.0)

Set insets of a text frame

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - valid text frame
0 : Use the current textmodel. In case of chained frames, the second parameter verfies the frame.
pos int - text position to verify the frame in case of chained text frames and frameRef = 0

Under comet_pdf the first frame of chain is used always.
l, t, r, b float - insets in points (left, top, right, bottom)
textInset float 0.0 inset of the text

Unused for now.
#include "internal/text.h"

Version 1.4 (R 336), 19. April 2007

priint:comet InDesign® Plug-Ins, comet_pdf
get_insets

static int justify(
  ItemRef frameRef,
  int pos,
  int len,
  int page = -1,
  char* layerName = "",
  int keepLast = 1,
  char* style1 = "",
  ...)

Vertical justification.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - valid text frame
0 : Use the current textmodel.
pos int - Apply function from the frame containing this text position. With a frame given (frameRef != 0) all values except kBegin are ignored.

kBegin : begin of the text
len int - Apply the function till the frame containing the text position pos+len.

kEnd : end of text
page int - In case of chained frames, frames can stay on different pages and layers. You may limit the the justification to one page by giving a page number:

-1 : all pages
otherwise : 1-based page number
layerName String or char* - In case of chained frames, frames can stay on different pages and layers. You may limit the the justification to one layer by giving a layer name:

"" : all layers
"--visible--" : visible layers only
"--active--" : active layer only
otherwise : valid layer name
keepLast int - 1 : Leave the last frame of a text chain untouched

0 : Can change the last frame too
style1, percent1, ... String or char*, float, ... - List of paragraph style names and percentages (float). With the percentage you can determine how much space is occupied for justification by this style. Be sure the arguments add up to 100.0 percent.

0 oder "" : Wildcard for "any" style
#include "internal/text.h"

Here you can find a (german) test document

 

Apply a vertical justification for the current script frame - but not if it is the last frame of a chain of text frames. But, if it is a last frame, reset all spaces before the paragraphs in this frame.

#include "internal/text.h"
#include "internal/types.h"
int main() { ItemRef succ = item::alloc (); int succRes = frame::get_link (gFrame, succ); int tpos = frame::get_textpos (gFrame);
if (succRes == 0 && !frame::is_valid (succ)) { textmodel::justify_reset (gFrame, tpos); }
textmodel::justify (gFrame, 0, kFrameEnd);
return 0; }

Version 1.4 (R 339), 2. Mai 2007

priint:comet InDesign® Plug-Ins
justify_reset
document::justify_text

static int justify_reset(
  ItemRef frameRef,
  int pos,
  int len = 0,
  int page = 0,
  char* layerName = 0,
  int keepLast = 0,
  char* style1 = 0,
  ...)

Reset vertical justification.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - valid text frame
0 : Use the current textmodel.
pos int - Apply function from the frame containing this text position.
len int - Unused since R1401 Apply the function till the frame containing the text position pos+len.

kEnd : end of text
page int - Unused since R1401In case of chained frames, frames can stay on different pages and layers. You may limit the the justification to one page by giving a page number:

-1 : all pages
otherwise : 1-based page number
layerName char* - Unused since R1401In case of chained frames, frames can stay on different pages and layers. You may limit the the justification to one layer by giving a layer name:

"" : all layers
"--visible--" : visible layers only
"--active--" : active layer only
otherwise : valid layer name
keepLast int - Unused since R1401

1 : Leave the last frame of a text chain untouched

0 : Can change the last frame too
style1, ... - char*, ... Unused since R1401 List of paragraph styles to reset to the style definition
#include "internal/text.h"

Here you can find a (german) test document

 

Version 1.4 (R 339), 2. Mai 2007
Parameters len, page, layerName, keepLast, style1, ...are unused since R1401.

priint:comet InDesign® Plug-Ins
justify
document::justify_text_reset
frame::get_textpos
frame::get_link

static int remove_redundant_tags(int startPos = 0, int len = -1)

Clean up textplaceholders. Text attribut changes such as font, textsize, color, ... are breaking the Comet placeholders into several so called runs. The Comet plug ins are runs save. But for saviong templates and document templates it would be a good idea, to remove this redundant information for performance reasons.

Using the application menu Plg Ins:Placeholder:Remove redundant placeholder before save users can remove redundant placeholders automatically.

The function removes all redundant placeholders from the current textplaceholder. Position and length are placeholder relative. To work with text relative positions, pleae use gremove_redundant_tags.

Name Type Default Description
Return int   0 or ErrorCode
startPos int 0 placeholder relative text start position
len int kEnd Length of text to work on or kEnd, kEnd means the end of the placeholder
#include "internal/text.h"

Version 1.4.1 R417, 24. Jul 2007

priint:comet InDesign® Plug-Ins
textmodel::gremove_redundant_tags
document::remove_redundant_tags
frame::remove_redundant_tags

static int gremove_redundant_tags(int startPos = 0, int len = -1)

Clean up textplaceholders. Text attribut changes such as font, textsize, color, ... are breaking the Comet placeholders into several so called runs. The Comet plug ins are runs save. But for saving templates and document templates it would be a good idea, to remove this redundant information for performance reasons.

Using the application menu Plg Ins:Placeholder:Remove redundant placeholder before save users can remove redundant placeholders automatically.

The function removes all redundant placeholders from the given range of the current textmodel. Position and length are text relative. To work with placeholder relative positions, pleae use remove_redundant_tags.

Name Type Default Description
Return int   0 or ErrorCode
startPos int 0 text relative start position
len int kEnd Length of text to work on or kEnd, kEnd means the end of the current text
#include "internal/text.h"

Version 1.4.1 R417, 24. Jul 2007

priint:comet InDesign® Plug-Ins
textmodel::remove_redundant_tags
document::remove_redundant_tags
frame::remove_redundant_tags

static Scrap cut(
  ItemRef frameRef = 0,
  int start = 0,
  int len = -1)

Remove text from the document and copy it into an internal scrap. The scrap will contain all styles attributes of the text, included images, tables, ... of the given text range. Text positions are relative to the text model, not to the scripts placeholder. The retreived scrap can use to insert the text into this or any other document again by using textmodel::paste. But you can use scraps only once. After using the scrap, it becomes invalid and will InDesign cause to crash by a second paste.

Name Type Default Description
Return Scrap   Created scrap of the cutted text or 0 in case of some errors.
frameRef ItemRef 0 Valid text frame reference

0 : current text frame
start int 0 Start here to cut. Text positions are relative to the text model, not to the scripts placeholder.
len int kEnd Length of text to cut. Text positions are relative to the text model, not to the scripts placeholder.
#include "internal/text.h"

Version 2.0 R646, 27. März 2008

priint:comet InDesign® Plug-Ins
textmodel::copy
textmodel::paste

static Scrap copy(
  ItemRef frameRef = 0,
  int start = 0,
  int len = -1)

Copy document text into an internal scrap. The scrap will contain all styles attributes of the text, included images, tables, ... of the given text range. Text positions are relative to the text model, not to the scripts placeholder. The retreived scrap can use to insert the text into this or any other document again by using textmodel::paste. But you can use scraps only once. After using the scrap, it becomes invalid and will InDesign cause to crash by a second paste.

Name Type Default Description
Return Scrap   Created scrap of the copied text or 0 in case of some errors.
frameRef ItemRef 0 Valid text frame reference

0 : current text frame
start int 0 Start here to copy. Text positions are relative to the text model, not to the scripts placeholder.
len int kEnd Length of text to copy. Text positions are relative to the text model, not to the scripts placeholder.
#include "internal/text.h"

Version 2.0 R646, 27. März 2008

priint:comet InDesign® Plug-Ins
textmodel::cut
textmodel::paste

static Scrap paste(
  ItemRef frameRef,
  Scrap data,
  int start = 0)

Insert a scraped text into a document. The scrap will contain all styles attributes of the text, included images, tables, ... of the given text range. Text positions are relative to the text model, not to the scripts placeholder. Use scraps only once. After using the scrap, it becomes invalid and will InDesign cause to crash by a second paste.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame reference

0 : current text frame
scrap Scrap - Scrap to insert from.
start int 0 Insert scrap at this position. Text positions are relative to the text model, not to the scripts placeholder.
#include "internal/text.h"

Copy the current text selection an append it to the current text.

#include "internal/types.h"
#include "internal/text.h"
int main () { Scrap scrap = textmodel::copy (0, kSelection);
textmodel::paste (0, scrap, kEnd);
return 0; }

Version 2.0 R646, 27. März 2008

priint:comet InDesign® Plug-Ins
textmodel::cut
textmodel::copy

static int insert_crossref(
  int index,
  int len,
  char* name,
  int classid = 0,
  int id = 0,
  int id2 = 0,
  int id3 = 0,
  char* sid = "",
  int borderVisble = 0,
  int borderWidth = 1,
  int borderHilite = 3,
  int borderStyle = 1,
  float borderCol1 = -1.0,
  float borderCol2 = -1.0,
  float borderCol3 = -1.0,
  float borderCol4 = -1.0,
  int* delBefore = 0)

Insert a cross reference destination into a text. This destination is not allowed to overlap different Comet placeholders. It is strongly recommended to use 0 as the destination length, but you can use longer destinations if you want. A cross reference destination will insert one (invisible, but existing) character into the text. Position is placeholder relative. Use frame::insert_crossref to insert cross reference destinations text frame relative.

A detailed description about Comet cross references you will find here.

Name Type Default Description
Return int   0 or ErrorCode
index int - placeholder relative position of the cross reference destination
len int - Number of characters occupied by destination. It is strongly recommended to use 0 as the destination length! But if you want ... .
name String or char* - reference name

"" : Cross reference is used as to be the name
classid int 0 Class number of the object
id, id2, id3 int 0 object IDs
sid String or char* "" StringID of the object
borderVisble int 0 visible in document?

0 : No
1 : Yes
borderWidth int 1 Frame width

1 : Thin
2 : Middle
3 : Bold
borderHilite int 3 Frame type
1 : Draw reference inverted (Not supported in InDesign®, but visible in PDF export.)
2 : Inset
3 : Outline
borderStyle int 1 Frame border style. InDesign® only supports the following two values:
0 : Continuous
1 : Dashed
borderCol1, borderCol2, borderCol3, borderCol4 float -1.0 Frame color in the range of 0.0 - 100.0 (or -1.0).

First three defined : use RGB
Four defined colors - use CMYK (don't work for now, sorry)
otherwise : Orange
delBefore int* 1 Attention : Its an address!. Automatically remove a reference of same name and Comet ID at the insertion point index. On return it contains whether a reference was deleted (1) or not (0).
#include "internal/text.h"

Create a cross reference destination. To run the script, select a product and a piece of text.

int main ()
{
    ItemRef 	frame		= item::alloc();
    String		str			= string::alloc ();
    Table		t			= table::alloc ();
    List 		prod 		= list::alloc (3,2,1); 	// product pool, selected entries, id1
    List 		prod2 		= list::alloc (3,2,2); 	// product pool, selected entries, id2
    List 		prod3 		= list::alloc (3,2,3); 	// product pool, selected entries, id3
    StringList	prodsid 	= stringlist::alloc (3, 2);
    int 		start, len, col, row;
    int			res;
    int			delBefore	= 1;
if (list::length (prod) == 0) { showmessage ("No product selected"); return 0; }
textmodel::selection (&start, &len, frame, 0, t, &col, &row); if (len > 0) textmodel::gettext (str, start, len);
res = textmodel::insert_crossref (   start, len,   string::get (str), // Name   3, // ClassID   list::get (prod, 0),   list::get (prod2, 0),   list::get (prod3, 0),   stringlist::get (prodsid, 0),   1,   3, // 1-3 Frame weight   3, // 1 Invert, 2 Inset, 3 Outline   1, // 0 Solid, 2 Dashed   100.0, 0.0, 0.0, -1.0,   &delBefore);
return 0; }

Version 2.1 R668, 14. April 2008

priint:comet InDesign® Plug-Ins
document::update_crossrefs
hyperlink::find
hyperlink::find1
link
w2cross-Tag
comet.CTextModel.insertCrossRef

static int scale_font(
  ItemRef frameRef,
  int pos,
  int len,
  float xscale,
  int chunkWise = 1,
  int doLeading = 1,
  int checkOverset = 0,
  int intSizesOnly = 0,
  float minSize = 0.0,
  float maxSize = 0.0,
  int useSizesAsLimits = 0,
  float paraScaleX = 0.0,
  float paraScaleY = 0.0,
  ...)

Scale the font size of a given text.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame reference

0 : current text
pos int - start position for scaling (0-based)

kSelection : current text selection, len is ignored in this case

kEnd : Tend of text
xscale float - fatcor to scale (1.0 means 100 percent, 0.5 half size, ...)
chunkWise int 1 0 : Use the scaled text size at pos for the complete text range

1 : use local font sizes
doLeading int 1 Scale leading too?

1 : Yes
0 : No
checkOverset int 0 How to deal with text over- and underset?

0 : Ignore (Scale exactly once)

1 : If the scaling produces an overset, the text size is shrinked, until the overset is fixed.

2 : Scale the given text so, that the text fills the frame as good as possible. xscale is ignored in this case.
intSizesOnly int 0 0 : any text sizes allowed
1 : only integer sizes allowed
minSize float 2.0 Lower size allowed (must be 2.0 at least). If one part of the text will getting smaller, the functions breaks.
maxSize float 0.0 Upper bound for font size

0.0 : ignore
otherwise : If one part of the text will getting greater, the functions breaks.
useSizesAsLimits int 0 Use minSize and maxSize as limits for the new font sizes, e.g. it means, any text smaller or bigger than this values will become this size.
paraScaleX, paraScaleY float, float 0.0, 0.0 If both values are greater than 0.0, paragraph properties are scaled by this values.
... String or char*, int, float, float Leer Four values each consting of property name, a flag, and a minimum and maximum value. Properties are always changed in all paragraph attached by the given range [po, pos+len]. If the list is empty, all appropirate properties are scaled.

The following properties are supported:

"All_Off" : Disable all. Useful if you only want to change some of the properties. Start your list with "All_Off", 0, 0.0, 0.0 followed by the properties you wish to scale.

"LeftIndent"
"RightIndent"
"FirstLineIndent"
"SpaceBefore"
"SpaceAfter"
"RuleAbove_Stroke"
"RuleAbove_LeftIndent"
"RuleAbove_RightIndent"
"RuleAbove_Offset"
"RuleBelow_Stroke"
"RuleBelow_LeftIndent"
"RuleBelow_RightIndent"
"RuleBelow_Offset"
"WordSpace_Min"
"WordSpace_Desired"
"WordSpace_Max"
"LetterSpace_Min"
"LetterSpace_Desired"
"LetterSpace_Max"
"HyphenZone"
"Tabs" You can only scale all positions or none.

Flag is an bit field with the following values defined

0 : Do not change property
1 : Scaling activated
2 : Check range given by value 3 and 4
4 : integer sizes allowed only



Values 3 and 4 are the minimum and maximum values (float), ignored if bit 2 is not set in flag.
#include "internal/text.h"

Fit the text into its frame.

#include "internal/text.h"
#include "internal/types.h"
int main () { textmodel::scale_font ( 0, // current textmodel 0, kEnd, 1.1, // factor 1, // chunkwise 1, // leading 2); // check for overset return 0; }

Fit text and and some paragrapth properties.

#include "internal/text.h"
#include "internal/types.h"
int main () { textmodel::scale_font ( 0, // current textmodel 0, kEnd, 1.1, // factor 1, // chunkwise 1, // leading 2, // check for overset 0, 0.0, 0.0, 0, "All_Off", 0, 0.0, 0.0, "RuleAbove_Stroke", 1, 0.0, 0.0, "RuleAbove_Offset", 1, 0.0, 0.0, "Tabs", 7, 10.0, 200.0); return 0; }

Version 2.1 R713, 14. Mai 2008
useSizesAsLimits since Version 2.1 R835, 28. July 2008
paraScaleX and following parameters sice version 3.1 R1928, 10. June 2010

priint:comet InDesign® Plug-Ins
scale_text

static int scale_text(
  ItemRef frameRef = 0,
  int pos = 0,
  int len = -1,
  float xscale = 0.0,
  int checkOverset = 1,
  int scaleInsets = 0)

Scaling a text or text range and its character and paragraph properties.

Name Type Default Description
Return int   0 or ErrorCode Normally, tables inside the text may not shrink to any (small) sizes. In this case, the functions gives up after some loops and returns the error tableInOversetErr (1259).
frameRef ItemRef 0 Valid text frame reference

0 : current text
pos int 0 start position for scaling (0-based)

kSelection : current text selection, len is ignored in this case

kEnd : Tend of text
xscale float kEnd fatcor for scaling (1.0 means 100 percent, 0.5 half size, ...)

0.0 : fit text to frame
checkOverset int 1 Check overset after scaling?

0 : No
1 : Avoid overset after scaling by downscaling the text

Ignored if xscale = 0.0.
scaleInsets int 0 Scale inseta as well?

0 : No
1 : Yes
#include "internal/text.h"

Parameter scaleInsets since v4.1.6 R25445, 9. Jul 2019
Version 2.1 R1926, 10. Juni 2010

priint:comet InDesign® Plug-Ins, Illustrator
scale_font

static int link_to_file(
  ItemRef frameRef,
  char* path,
  int importStyleTable = 1,
  int importSwatchList = 1,
  int importXMPData = 1,
  int importXMLTagList = 1)

Link the text frame against an InCopy (incd) file. Any existing text is replaced by the InCopy file.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame reference

0 : current text
path String or char* - Path to the file which the frame should be linked to. Has to be an InCopy-File (incd). If the extension is missing, it is automatically added.
importStyleTable int 1 Import paragraph styles, character styles, ...?
importSwatchList int 1 Import swatches?
importXMPData int 1 Import XMP-Header?
importXMLTagList int 1 Import XML-Tags?
#include "internal/text.h"

Version 2.1 R1120, 14. January 2009

priint:comet InDesign® Plug-Ins

static int export_and_create_link(
  ItemRef frameRef,
  char* path,
  int encoding = 0,
  int suppressStyleTable = 1,
  int suppressSwatchList = 1,
  int suppressXMPData = 1,
  int suppressXMLTagList = 1)

Link the text frame against an InCopy (incd) file. Any existing text is replaced by the InCopy file.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame reference

0 : current text
path String or char* - Path to the file which the frame should be linked to. Has to be an InCopy-File (incd). If the extension is missing, it is automatically added.
enc int 0 Encoding

0 : UTF-8
1 : UTF-16
3 : Shift-JIS
suppressStyleTable int 0 supress exporting paragraph styles, character styles, ...? (due to an error in CS3 supported since CS4 )
suppressSwatchList int 0 supress exporting swatches? (due to an error in CS3 supported since CS4 )
suppressXMPData int 0 supress exporting XMP-Header? (due to an error in CS3 supported since CS4 )
suppressXMLTagList int 0 supress exporting XML-Tags? (due to an error in CS3 supported since CS4 )
#include "internal/text.h"

Version 2.1 R1120, 14. January 2009

priint:comet InDesign® Plug-Ins

static int export_html(
  char* outputFolder,
  char* outputName,
  int startPos = 0,
  int length = -1,
  int copyImages = 0,
  char* resultString = 0,
  char* title = 0,
  char* css = 0,
  int flags = 0)

Export the textmodel as an HTML file.
Style information is put into a seperate .css file into a subfolder in the target folder.
More information can be founde here.

Name Type Default Description
Return int   0 or ErrorCode
outputFolder String or char* - Target folder
outputName String or char* - Name of the target file (without extension)
startPos int 0 Start index in the text model
length int -1 Length in the text model (-1 = until the end)
copyImages int 0 Just link images or copy them? (0 = link, 1 = copy)
resultString String or char* 0 Write the result to this string - when provided prevents writing to file
title String or char* 0 Title for the html document (uses the filename by default)
css String or char* 0 Use this as CSS (Either a path to a CSS file or a string containing styles)
flags int 0 Additional export options
Combination of the following flags:
kExportUnsupported (Non HTML-supported image formats are exported as .png)
kExportNonExisting (Non existing images are exported as .png from the previews)
#include "internal/types.h"
#include "internal/text.h"

4.0.5 R8568

priint:comet InDesign® Plug-Ins
frame::export_html

static int is_linked(ItemRef frameRef)

Check whether the given textframe is linked against an InCopy file.

Name Type Default Description
Return int   0 : Not linked (or error)
1 : Yes
frameRef ItemRef - Valid text frame reference

0 : current text
#include "internal/text.h"

Version 2.1 R1120, 14. January 2009

priint:comet InDesign® Plug-Ins
get_linkpath

static char* get_linkpath(ItemRef frameRef)

Get the path of a (InCopy) linked text frame.

Name Type Default Description
Return char*   Complete path to the linked InCopy file or empty.

The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o char* values.

frameRef ItemRef - Valid text frame reference

0 : current text
#include "internal/text.h"

Version 2.1 R1120, 14. January 2009

priint:comet InDesign® Plug-Ins
is_linked

static int inline_(
  int pos,
  ItemRef frameRef = 0,
  int flag = 1,
  float yoff = 0.0,
  int lock = 0)

Change a frame to a text inline or anchored frame.

Name Type Default Description
Return int   0 or Error rcode
textFrameRef ItemRef - valid frame reference
pos int - Text position for inline
frameRef ItemRef 0 Frame to inline. May be emtpy if flag = 2

On successful return it contains the new frame reference.

Changed on successful return!
flag int 1 What to do, if an inline exists at the given position already?

0 - create anyway
1 - delete an recreate
2 - do not create, but change
yoff float 0.0 y-offset given in points
lock int 0 Suppress manual changes

0 : no
1 : yes
#include "internal/text.h"

See frame::anchor und frame::inline_ for expamples.


Version 2.1 R1145, 28. Jan 2009

priint:comet InDesign® Plug-Ins, comet_pdf
frame::inline_above
frame::anchor
frame::get_anchor
frame::inline_
release_inline

static int inline_above(
  int pos,
  ItemRef frameRef = 0,
  int flag = 1,
  int halign = 3,
  float spaceBefore = 0.0,
  float spaceAfter = 0.0,
  int lock = 0)

Create an "inline above" frame at a given text position. You may use this function to change the inline properties of an existing frame too.

Name Type Default Description
Return int   0 or ErrorCode
pos int - text position to create/change the inline frame
frameRef ItemRef 0 Frame to convert to an inline. On successful return it contains (the changed) reference to the new inline. May be empty if flag = 2 ist.
flag int 1 What to do, if the given text position already points to an inline or anchored object?

0 -create anyway
1 - delete an recreate
2 - change properties only
halign int 3 horizontal alignment

0 : right
1 : centre
2 : left
3 : text alignment
4 : torwards spine
5 : away from spine
spaceBefore float 0.0 space before the inline in points
spaceAfter float 0.0 space after the inline in points
lock int 0 prevent manual positioning

0 : no
1 : yes
#include "internal/text.h"

See frame::anchor und frame::inline_above for expamples.


Version 2.1 R1145, 28. Januar 2009

priint:comet InDesign® Plug-Ins, comet_pdf
frame::inline_
frame::anchor
frame::get_anchor
inline_
release_inline

static int anchor(
  int pos,
  ItemRef frameRef = 0,
  int flag = 1,
  int spine = 0,
  int ref_obj = 0,
  int ref_pt = 3,
  int xrel = 4,
  float xoff = 0.0,
  int yrel = 4,
  float yoff = 0.0,
  int keepWithin = 1,
  int lock = 0)

Make a frame an anchored frame at a text position. You may use this funtion to change the properties of an anchored frame at a given text position too.

Name Type Default Description
Return int   0 or ErrorCode
pos int - text position of anchored frame
frameRef ItemRef 0 Frame to convert to an anchored frame. On successful return it contains (the changed) reference to the new anchored frame. May be empty if flag = 2 ist.
flag int 1 What to do, if the given text position already points to an inline or anchored object?

0 -create anyway
1 - delete an recreate
2 - change properties only
spine int 0 Relative to spine

0 : No
1 : Yes
ref_obj int kRefPointTopLeft Object anchor

kRefPointTopLeft
kRefPointTopCenter
kRefPointTopRight
kRefPointLeftCenter
kRefPointCenter
kRefPointRightCenter
kRefPointBottomLeft
kRefPointBottomCenter
kRefPointBottomRight
ref_pt int kRefPointLeftCenter reference point. Attention : Not all reference points are supported by all frame preferences!

kRefPointTopLeft
kRefPointTopCenter
kRefPointTopRight
kRefPointLeftCenter
kRefPointCenter
kRefPointRightCenter
kRefPointBottomLeft
kRefPointBottomCenter
kRefPointBottomRight
xrel int 4 x relative to

0 : column edge
1 : text frame
2 : page margin
3 : page edge
4 : anchor marker
xoff float 0.0 "x-Offset" in points
yrel int 4 y relativ zu

0 : column edge
1 : text frame
2 : page margin
3 : page edge
4 : line (Baseline)
5 : line (Height of X)
6 : line (Cap height)
7 : line (Botto of Leading)
8 : line (Top of Leading)
9 : Em-Box top
10 : Em-Box centre
11 : Em-Box bottom
yoff float 0.0 "y-Offset" in points
keepWithin int 1 Keep within Top/Bottom column boundaries

0 : no
1 : yes
lock int 0 Prevent manual positioning

0 : no
1 : yes
#include "internal/types.h"
#include "internal/text.h"

Version 2.1 R1145, 28. Januar 2009

priint:comet InDesign® Plug-Ins, comet_pdf
inline_
inline_above
get_anchor
frame::anchor

static int get_anchor(
  int pos,
  int len,
  int* out_pos,
  int* out_type = 0,
  ItemRef out_frameRef = 0,
  int* rel_to_spine = 0,
  int* refpoint_obj = 0,
  int* refpoint_pt = 0,
  int* xrel = 0,
  float* xoff = 0,
  int* yrel = 0,
  float* yoff = 0,
  int* keepWithin = 0,
  int* locked = 0,
  int* halign = 0,
  float* spaceBefore = 0,
  float* spaceAfter = 0,
  float* yoff_inline = 0 )

Get the properties of an inline-above or anchored frame. If an object is found at the given text position, the appropriate out variables for the object type are filled.
Set variables, you do not need to 0.

Name Type Default Description
Return int   0 or ErrorCode Error code 0 (no error) does NOT mean, that no inline was found at the given position. No object found you can see at out_pos == -1. kein Inline oder verankerter Rahmen gefunden wurde. Ob ein solches Objekt gefunden wurde, gibt die Variable out_pos == -1 an.}
pos int - Search for an inline in the given text range. The range ist given relative to frame, not to the placeholder.
len int - Search for an inline in the given text range (min 1). The range ist given relative to frame, not to the placeholder.

kEnd : end of text
out_pos int* 0 on return : position of the first inline object
-1 : no inline found in the given range
out_type int* 0 Object type

0 : Inline
1 : Anchored frame
2 : Inline above
out_frameRef ItemRef 0 Anchored frame. 0 or allocte before by item::alloc
rel_to_spine int* 0 Anchored frames only, out_type == 1 Relative to spine?
refpoint_obj int* 0 Anchored frames only, out_type == 1 Reference point of the object
refpoint_pt int* 0 Anchored frames only, out_type == 1 Reference point of anchor
xrel int* 0 Anchored frames only, out_type == 1
xoff float* 0 Anchored frames only, out_type == 1 x-offset in points
yrel int* 0 Anchored frames only, out_type == 1
yoff float* 0 Anchored frames only, out_type == 1 y-offset in points
keepWithin int* 0 Anchored frames only, out_type == 1 Not not move away from frame
locked int* 0 out_type == 0 | 1 | 2
halign int* 0 Inline aboves only, out_type == 2
spaceBefore float* 0 Inline aboves only, out_type == 2 given in points
spaceAfter float* 0 Inline aboves only, out_type == 2 given in points
yoff_inline float* 0 Inlines only, out_type == 0 y-offset in points
#include "internal/types.h"
#include "internal/text.h"

See frame::anchor and frame::inline_above for examples.


Version 2.1 R1145, 28. Januar 2009

priint:comet InDesign® Plug-Ins, comet_pdf
frame::inline_
frame::inline_above
frame::anchor
get_anchor

static int set_parastyle(
  ItemRef frameRef,
  int startPos,
  int len,
  char* stylePath,
  int overrideLocals = 1,
  char* exceptThese = "")

Set a paragraph style for all paragraphs intersecting a given text range. Since CS4 styles can be organized in folders. ":" is used as to be the path delimiter - therefore you cannot use ":" in style names. In text placeholders the funktion is limited to the text range belonging to the placeholder.

Name Type Default Description
Return int   0 or error code
frameRef ItemRef - Valid text frame

0 : current text
startPos int - Start position
>= 0 text position
kSelection current text selection
len int - lemgth of text

kEnd end of text
>=0 : number of letters

Ignored if start == kSelection.
stylePath String or char* - Style name or path with ':' as delimiter
overrideLocals int 1 Override local settings? This is the description of the parameter in Adobe's InDesign plugin SDK : IN whether to clear the overrides.

1 : Yes
0 : No
exceptThese String or char* "" Do not change these paragraph styles. The specification is only evaluated by comet_pdf!

The string can contain multiple paragraph styles, even non-existent ones. Individual style names are separated by blanks. If a style name contains blanks, the name must be enclosed in quotation marks. A valid specification would be e.g.:

"aaa \"bbb\" ccc
#include "internal/types.h"
#include "internal/text.h"

Version 2.1, R 1580, 1. Okt. 2009
Parameter rmvOverrides since v4.1.8 R29556

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator
frame::set_objectstyle
textmodel::set_charstyle
get_parastyle
comet.CTextModel.setParaStyle

static int set_charstyle(
  ItemRef frameRef,
  int startPos,
  int len,
  char* stylePath,
  int overrideLocals)

Set a character style for a given text range. Since CS4 styles can be organized in folders. ":" is used as the path delimiter - therefore you cannot use ":" in styles names. In text placeholders the function is limited to the text range belonging to the placeholder.

Name Type Default Description
Return int   0 or error code
frameRef ItemRef - Valid text frame

0 : current text
startPos int - Start position
>= 0 text position
kSelection current text selection
len int - length of text

kEnd end of text
<=0 : number of letters

Ignored if start == kSelection.
stylePath String or char* - Style name or path with ':' as delimiter
overrideLocals int 1 Override local settings? This is the description of the parameter in Adobe's InDesign plugin SDK : IN whether to clear the overrides.

1 : Yes
0 : No
#include "internal/text.h"

Version 2.1, R 1580, 1. Okt. 2009
comet_pdf since v4.2 R33590, 14. Oct 2023

priint:comet InDesign® Plug-Ins, Illustrator, comet_pdf
frame::set_objectstyle
textmodel::set_charstyle
get_parastyle
comet.CTextModel.setCharStyle

static char* get_parastyle(
  ItemRef frameRef,
  int pos,
  int* runStart = 0,
  int* runLength = 0,
  int fullPath = 0)

Get the paragraph style of a given text position In text placeholders the funktion is limited to the text range belonging to the placeholder.

Name Type Default Description
Return char*   Paragraph style at the given text position or empty.

The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o char* values.

frameRef ItemRef - Valid text frame reference

0 : current text frame
pos int - text position

>= 0 0-based text position
kSelection Current text selection (InDesign only!)
runStart int* 0 On successful return: Paragraph style starts here. May be 0.
runLength int* 0 On successful return: Number of characters using this style. May be 0.
fullPath int 0 Get the full path of the style name or only its name

0 : Name only
1 : Complete path
#include "internal/text.h"

Write the paragraph and character style of the current selection in the log. The script only works with InDesign!

int main ()
{
    int			start, len;
    char		str [8000];
strcpy (str, textmodel::get_parastyle (0, -2, &start, &len)); wlog ("", "# [%d, %d] : Parastyle '%s'\n", start, len, str);
strcpy (str, textmodel::get_charstyle (0, -2, &start, &len)); wlog ("", "# [%d, %d] : Charstyle '%s'\n", start, len, str);
return 0; }

Write all paragraph styles of a text in the log file.

#include "internal/text.h"
int main () { int pos = 0, len; char * style;
while (1) { style = textmodel::get_parastyle (gFrame, pos, &pos, &len, 0); pos = pos + len + 1; if (!style) break;
wlog ("", "[%d, %d] : '%s'\n", pos, pos+len, style);
if (pos >= frame::textlength (gFrame)) break; }
return 0; }

Version 3.1 R1849, 4. Mai 2010 nameOnly since Version 3.1 R1881, 26. May 2010

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator
set_parastyle
get_charstyle
comet.CTextModel.getParaStyle

static char* get_charstyle(
  ItemRef frameRef,
  int pos,
  int* runStart = 0,
  int* runLength = 0,
  int nameOnly = 1)

Get the character style of a given text position In text placeholders the funktion is limited to the text range belonging to the placeholder.

Name Type Default Description
Return char*   Character style at the given text position or empty.

The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o char* values.

frameRef ItemRef - Valid text frame reference

0 : current text frame
pos int - text position
>= 0 0-based text position
kSelection current text selection
runStart int* 0 character style starts here. May be 0.
runLength int* 0 Number of characters using this style. May be 0.
nameOnly int 0 Get the full path of the style name or only its name

0 : name only
1 : complete path
#include "internal/text.h"
int main ()
{
    int			start, len;
    char		str [8000];
strcpy (str, textmodel::get_parastyle (0, -2, &start, &len)); wlog ("", "# [%d, %d] : Parastyle '%s'\n", start, len, str);
strcpy (str, textmodel::get_charstyle (0, -2, &start, &len)); wlog ("", "# [%d, %d] : Charstyle '%s'\n", start, len, str);
return 0; }

Version 3.1 R1849, 4. Mai 2010
nameOnly since Version 3.1 R1881, 26. May 2010

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator
set_charstyle
get_parastyle
comet.CTextModel.getCharStyle

static int find_surrounding_word(ItemRef frame, int* len = 0)

Get the beginning (and possible length) of a word at a given text position.

Name Type Default Description
Return int   text position of beginning of the word or -1 in case of any error
frameRef ItemRef - Valid text frame

0 : current text frame
pos int - text position
>= 0 0-based text position. The position is relative to the placeholder in placeholder scripts but the result is text realtiv in every case.
kSelection current text selection
len int* 0 Length of word in letters
#include "internal/text.h"
int main ()
{	
    int			start	= 0;
    int			p		= 0;
    int 		len;
    String		str		= string::alloc ();
while (1) { start = textmodel::find_surrounding_word (gFrame, start, &len); if (start < 0) break;
if (len) { p++; frame::gettext (gFrame, str, start, len); wlog ("", "Word %d : %d '%s'\n", p, start, string::get (str)); start += len; } else ++start;
}
return 0; }

Version 2.1, R 1590, 8. Okt. 2009

priint:comet InDesign® Plug-Ins, comet_pdf
find_surrounding_paragraph

static int find_surrounding_paragraph(
  ItemRef frame,
  int startPos,
  int* len = 0,
  int placeholderRelative = 1)

Get the beginning (and possible length) of a paragraph at a given text position.

Name Type Default Description
Return int   text position of paragraph beginnning or -1 in case of any error
frameRef ItemRef - Valid text frame

0 : current text frame
pos int - text position
>= 0 0-based text position. The position is relative to the placeholder in placeholder scripts but the result is text realtiv in every case.
kSelection current text selection
len int* 0 Length of paragraph in letters. Length includes the internal story end character.
placeholderRelative int 1 Is the value of pos relative to the placeholder or relativ to the complete text?

1 . relative to placeholder
0 : relative to the complete text
#include "internal/text.h"

Remove last paragraph until the frame has no overset.

#include "internal/types.h"
#include "internal/text.h"
int main () { int pstart; int plen; int flen = frame::textlength (gFrame);
while (flen > 0 && frame::overset (gFrame, kFullChain)) { pstart = textmodel::find_surrounding_paragraph (gFrame, flen-1, &plen); if (pstart >= 0) { frame::replace_all (gFrame, "", pstart, kEnd, 0); flen = frame::textlength (gFrame); } else flen = 0;
} return 0; }

Log all paragraphs. Attention: Because we are using wlog, do NOT use script for frames with paragraphs longer than 3000 letters.

int main ()
{	
    int			start 	= 0;
    int			p		= 0;
    int 		len;
    String		str		= string::alloc ();
while (1) { start = textmodel::find_surrounding_paragraph (gFrame, start, &len); if (start < 0) break;
p++; frame::gettext (gFrame, str, start, len); wlog ("", "Para %d : %d '%s'\n", p, start, string::get (str));
if (len )start += len; else ++start; }
return 0; }

Version 2.1, R 1590, 8. Okt. 2009
Parameter placeholderRelative seit v3.3.1, R3212, 11. Oct. 2012

priint:comet InDesign® Plug-Ins
find_surrounding_word

static int get_hyphenation(
  ItemRef frame,
  int textPos,
  int* method = 0,
  int* shortestWord = 0,
  int* minCharsBefore = 0,
  int* minCharsAfter = 0,
  int* ladderLimit = 0,
  float* zone = 0,
  int* capitalized = 0,
  int* weight = 0,
  int* lastWord = 0,
  int* acrossColumns = 0)

Get the current hyphenation settings for a paragraph.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - valid text frame

0 : current text frame
textPos int - Text position. You may use any text position inside the paragraph here.
>= 0 Textposition
kSelection current text selection Learn more
method int* 0 Hyphenation method

0 : off
1 : manually
2 : dictionary
3 : on
shortestWord int* 0 shortest word length
minCharsBefore int* 0 minimum letters to keep on old line
minCharsAfter int* 0 minimum letter on new line
ladderLimit int* 0 maximum number of following lines with hyphens (Hyphen limit)
zone float* 0 Hyphenation zone in points (0.0 - 8640.0)
capitalized int* 0 Can hyphenate capitalized words?
weight int* 0 Spacing versus Hyphens (0-10)

0 : Better spacing
:
10 : Fewer hyphens
lastWord int* 0 Can hyphenate last word?
acrossColumns int* 0 Hyphenate across columns?
#include "internal/text.h"

Version 2.1, R 1645, 6. Nov. 2009

priint:comet InDesign® Plug-Ins
set_hyphenation

static int set_hyphenation(
  ItemRef frame,
  int textPos,
  int method = -1,
  int shortestWord = -1,
  int minCharsBefore = -1,
  int minCharsAfter = -1,
  int ladderLimit = -1,
  float zone = -1.0,
  int capitalized = -1,
  int weight = -1,
  int lastWord = -1,
  int acrossColumns = -1)

Change the hyphenation settings for a paragraph.

Name Type Default Description
Return int   text position of paragraph begin or -1 in case of any error
frameRef ItemRef - valid text frame

0 : current text frame
textPos int - Text position. You may use any text position inside the paragraph here.
>= 0 Textposition
kSelection current text selection Learn more
method int -1 Hyphenation method

-1 : leave untouched
0 : off
1 : manually
2 : dictionary
3 : on
shortestWord int -1 shortest word length

-1 : leave untouched
minCharsBefore int -1 minimum letters to keep on old line

-1 : leave untouched
minCharsAfter int -1 minimum letter on new line

-1 : leave untouched
ladderLimit int -1 maximum number of following lines with hyphens (Hyphen limit)

-1 : leave untouched
zone float -1.0 Hyphenation zone in points (0.0 - 8640.0)

-1.0 : leave untouched
capitalized int -1 Can hyphenate capitalized words?

-1 : leave untouched
weight int -1 Spacing versus Hyphens (0-10)

-1 : leave untouched
0 : Better spacing
:
10 : Fewer hyphens
lastWord int -1 Can hyphenate last word?

-1 : leave untouched
acrossColumns int -1 Hyphenate across columns?

-1 : leave untouched
#include "internal/text.h"

Straight forward. But be carefull with get_hyphanation, in this case all variables must get a trailing &.

#include "internal/types.h"
#include "internal/text.h"
int main () { int method, shortestWord, minCharsBefore; int minCharsAfter, ladderLimit; float zone; int capitalized, weight, lastWord, acrossColumns;
textmodel::set_hyphenation (0, kSelection,   -1, // method   10, // shortest word   9, // minCharsBefore   8, // minCharsAfter   7, // ladderLimit   6.0, // zone   5, // weight (moderat)   );
textmodel::get_hyphenation (0, kSelection,   &method,   &shortestWord,   &minCharsBefore,   &minCharsAfter,   &ladderLimit,   &zone,   &capitalized,   &weight,   &lastWord,   &acrossColumns);
wlog ("", "Hyphenation :\n"); wlog ("", " Method %d\n", method); wlog ("", " ShortestWord %d\n", shortestWord); wlog ("", " MinCharsBefore %d\n", minCharsBefore); wlog ("", " MinCharsAfter %d\n", minCharsAfter); wlog ("", " LadderLimit %d\n", ladderLimit); wlog ("", " Zone %f\n", zone); wlog ("", " Capitalized %d\n", capitalized); wlog ("", " Weight %d\n", weight); wlog ("", " LastWord %d\n", lastWord); wlog ("", " AcrossColumns %d\n", acrossColumns);
return 0; }

Version 2.1, R 1645, 6. Nov. 2009

priint:comet InDesign® Plug-Ins
get_hyphenation

static int select(
  ItemRef frame,
  int start,
  int len,
  int scrollIntoView = 1)

Set document text selection.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame

current text frame
start int - Start of (new) text selection
len int - length of text selection
scrollIntoView int 1 Scroll selection into the visible window area?

1 : Yes
0 : No
#include "internal/text.h"

Version 3.2 R1920, 06.06.2010
Parameter scrollIntoView since v4.1.6 R26333, 18. Nov. 2019

priint:comet InDesign® Plug-Ins

static int create_cometgroup(
  ItemRef frame,
  int start,
  int len,
  int colorID = 0)

Create a Comet text group for a given text range.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame

current text frame
start int - Start of Comet text group
len int - length of text group
colorID int automatic Color used for the group. The colorID is the index of a color from the current datapool. If missing, an automatic colorID is used.
#include "internal/text.h"

Create a Comet text group from the current text selection.

#include "internal/text.h"
#include "internal/types.h"
int main () { textmodel::create_cometgroup (0, kSelection, 0, 3); return 0; }

Version 3.2 R1920, 06.06.2010

priint:comet InDesign® Plug-Ins

static int resolve_cometgroup(
  ItemRef frame,
  int pos,
  int len)

Resolve a Comet text group.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame

current text frame
pos int - Any text position of the group
len int 0 Length of range to remove Comet text groups. All groups intersecting the given range are removed.
#include "internal/text.h"

Resolve the Comet group at the beginning of current text selection.

#include "internal/text.h"
#include "internal/types.h"
int main () { textmodel::resolve_cometgroup (0, kSelection, 0); return 0; }

Version 3.2 R1920, 06.06.2010

priint:comet InDesign® Plug-Ins

static int get_cometgroup(
  ItemRef frame,
  int pos,
  int* start = 0,
  int* endpos = 0,
  IDType ids = 0,
  ...)

Get information about the identifier of a Comet text group.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame

current text frame
pos int - Any text position of the group
start int* 0 Start of group (0-based).
endpos int* 0 End position of group (0-based).
ids IDType 0 Group identifier.
... String or char*, int* or (String or char*) 0 Any number of key/value pairs to retrieve additional data. You my use any definition defined for placeholders ((see here).
#include "internal/text.h"
#include "internal/text.h"
#include "internal/types.h"
int main () { IDType tid = idtype::alloc (); int start, endPos; int colid;
textmodel::get_cometgroup (0, kSelection, &start, &endPos, tid, "Color", &colid); wlog ("", "#Comet-Textgroup [%d, %d] : %d-%d, %d (%s), Color %d\n",   start, endPos,   idtype::id (tid),   idtype::id2 (tid),   idtype::id3 (tid),   idtype::stringid (tid),   colid);
textmodel::change_cometgroup (0, 12, "Color", 3); textmodel::select_cometgroup (0, 12); return 0; }

Version 3.2 R1920, 06.06.2010

priint:comet InDesign® Plug-Ins

static int change_cometgroup(
  ItemRef frame,
  int pos,
  char* slot,
  int value)

Change a Comet text group.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame

current text frame
pos int - Any text position of the group
slot String or char* - What value to change? You may use any slot except "Format" defined for placeholders (see change placeholder), but only "Color" is used for now..
value int/String or char* - New value of the slot. See here for more infomation about the data type.
#include "internal/text.h"
#include "internal/text.h"
#include "internal/types.h"
int main () { IDType tid = idtype::alloc (); int start, endPos;
textmodel::get_cometgroup (0, kSelection, &start, &endPos, tid); wlog ("", "#Comet-Textgroup [%d, %d] : %d-%d (%s), color %d\n",   start, endPos,   idtype::id (tid),   idtype::id2 (tid),   idtype::stringid (tid),   idtype::id3 (tid));
textmodel::change_cometgroup (0, 12, "Color", 3); textmodel::select_cometgroup (0, 12); return 0; }

Version 3.2 R1920, 06.06.2010

priint:comet InDesign® Plug-Ins

static int select_cometgroup(ItemRef frame, int pos)

Select a Comet text group.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - Valid text frame

current text frame
pos int - Any text position of the group
#include "internal/text.h"
#include "internal/text.h"
#include "internal/types.h"
int main () { textmodel::select_cometgroup (0, kSelection); return 0; }

Version 3.2 R1920, 06.06.2010

priint:comet InDesign® Plug-Ins

static int use_global_index(int state = 1)

Use textmodel relative positions in the next (and only in the next) call to a textmodel function that normally uses placeholder relative positions. After

Name Type Default Description
Return int   ignorable
state int 1 1 : The next (and only the next) call of a textmodel function with placeholder relative positions uses textmodel relative positions instead.

0 : reset behavior
#include "internal/text.h"
int main ()
{
    textmodel::use_global_index ();
    textmodel::set_parastyle (gFrame, 0, 1, "Mein Stil");
    textmodel::use_global_index ();
    textmodel::insert ("aaa", 3);
return 0; }

Version 3.3 R2511, 17.06.2010

priint:comet InDesign® Plug-Ins

static int set_color(
  ItemRef frameRef,
  int start,
  int len,
  char* colName,
  float tint = 100.0)

Set the text color. The color is defined by its name.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - text frame reference

0 : current script frame
start, len int, int -, - text range (textmodel-based)
colName String or char* - Name of color or base color
tint float 100.0 0.0 - 100.0
#include "internal/text.h"

v3.2.3 R2600, 14.08.2011

priint:comet InDesign® Plug-Ins
set_color_rgb
set_color_cmyk
comet.CTextModel.setColor

static int set_color_rgb(
  ItemRef frameRef,
  int start,
  int len,
  int r,
  int g,
  int b)

Set the text color. The color is defined by its rgb values.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - text frame reference

0 : current script frame
start, len int, int -, - text range (textmodel-based)
r, g, b int, int, int -, -, - rgb values (0-255)
#include "internal/text.h"

v3.2.3 R2600, 14.08.2011

priint:comet InDesign® Plug-Ins
set_color
set_color_cmyk

static int set_color_cmyk(
  ItemRef frameRef,
  int start,
  int len,
  float c,
  float m,
  float y,
  float k)

Set the text color. The color is defined by its cmyk values.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - text frame reference

0 : current script frame
start, len int, int -, - text range (textmodel-based)
c. m, y, k 4 floats -, -, -, - 0.0 - 1.0
#include "internal/text.h"

v3.2.3 R2600, 14.08.2011

priint:comet InDesign® Plug-Ins
set_color
set_color_rgb

static int solve_overset(ItemRef frameRef, int method = 2)

Solve the overset of a textframe by creating and linking new frames on new document pages. Three methods are implemented:

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef - text frame reference

0 : current script frame
method int 2 Method to solve the overset

0 : Create new pages with duplicates of the last frame of the text. The new frames are fitted to the page.

1 : Create new pages with duplicates of the last frame of the text.

2 : Follow the current page template. If the page template does not contain any text element, error pageTemplateEmptyErr (= 1271) is returned. If no page template is defined for the page, use method=1.
#include "internal/text.h"

v3.3 R2892, 07.05.2012

priint:comet InDesign® Plug-Ins, comet_pdf

static int get_boundary_length(
  ItemRef frameRef,
  int pos,
  int* minPos = 0)

Get the length of a text piece. The length is given in InDesign® characters NOT in bytes. If pos points into a table cell, the function returns the number of characters in this cell, otherwise the length of the textmodel without any table cells.

Name Type Default Description
Return int   Number of characters of the text piece containing pos. The length is given in InDesign® characters NOT in bytes. If pos points into a table cell, the function returns the number of characters in this cell, otherwise the length of the textmodel without any table cells.
frameRef ItemRef - Valid text frame

0 : current script frame
pos int - Text model relative index in text..
minPos int* 0 Piece starts here.
#include "internal/text.h"

Build a text right before a placeholder. The text should NOT contain to the placeholder.

int myInsertBefore (int * pos, char * txt)
{
    int			oldLen		= textmodel::get_boundary_length (gFrame, *pos);
    int			inserted	= 0;
textmodel::use_global_index (); textmodel::insert (txt, *pos);
inserted = textmodel::get_boundary_length (gFrame, *pos) - oldLen; pos = *pos + inserted; if (inserted <= 0) return 0;
textmodel::use_global_index (); textmodel::clear_placeholders (*pos-inserted, inserted, gFrame);
return 0; }
int main () { int pos = gStart;
myInsertBefore (&pos, "QWERTZU123456789"); myInsertBefore (&pos, "abcdefgäö"); myInsertBefore (&pos, "---");
return 0; }

v3.3 R3243, 30.10.2012

priint:comet InDesign® Plug-Ins

static int dump(
  ItemRef frameRef = 0,
  int textpos = 0,
  int doPrint = 0,
  char* headline = 0,
  char* w2_info1 = 0,
  char* w2_info2 = 0,
  char* w2_info3 = 0,
  char* w2_info4 = 0)

Write the content of the given text model into the log file.

The call only has a meaning for comet_pdf. In InDesign®, only a note that the call was reached is written in the log.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef 0 Text frame

0 : Current text frame
headline String or char* "textmodel::dump" Headline of output
textPos int 0 Index of the required text

0 : Main text of the frame otherwise : Internal text index of a table cell, see table::cell::get_textpos
doPrint int 0 Write output also in Termninal? 0 : No, only write in the log file
1 : Write output (also) to Terminal
w2_info1, ... w2_info4 String or char* - If the text contains placeholders (w2), you can specify here which values of the placeholder should be written to be output. You can set up to four names for placeholder values here.
#include "internal/text.h"

v4.0.5 R11011, 2. Mai 2016
Parameter doPrint since v4.1.8 R30317

priint:comet InDesign® Plug-Ins, comet_pdf

The following functions are used to support Chinese, Japanese, and Korean (CJK) writing systems. These writing systems are supported by all InDesign® versions. But to set the properties you need a localized InDesign® version. In order to set basic properties of CJK writing systems also with 'normal' InDesigns®, we have created script commands for the most important text attributes. The implementation does not claim to be complete!

With the help of the menu Font -> Text Orientation -> Vertical you can change the text direction of a text frame manually.

static int set_orientation(ItemRef frameRef = 0, int orientation = 0)

Set the orientation of a text. Text can be orientated horizontal or vertical.

All frames of a text chain havin the same text oriantation always. Therefor, the function changes the text orientation of the whole chain always no matter, what from of the chain was given!

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef 0 Valid text frame

0 : Current script frame
orientation int 0 Text orientation

0 : horizontal
1 : vertical
#include "internal/text.h"

v4.0.5 R12350, 1. Aug 2016

priint:comet InDesign® Plug-Ins

static int get_orientation(ItemRef frameRef = 0)

Get the orientation of a text.

Name Type Default Description
Return int   -1 : Error
0 : horizontal
1 : vertical
frameRef ItemRef 0 Valid text frame

0 : Current script frame
#include "internal/text.h"

v4.0.5 R12350, 1. Aug 2016

priint:comet InDesign® Plug-Ins

static int set_composer(
  ItemRef frameRef = 0,
  int pos = 0,
  int len = -1,
  int composer = 1)

Set the text composer of a text.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef 0 Valid text frame

0 : Current script frame
pos int 0 Text position. The new composer is set from the beginning of the paragraph containing the position pos.
len int span[keyword]{kEnd} Number of characters. The new composer is applied until the end of the paragraph at least.

kEnd : End of text
composeer int 1 1 : Adobe Paragraph Composer
2 : Adobe Single-line Composer
3 : Adobe Japanese Paragraph Composer
4 : Adobe Japanese Single-line Composer
5 : Global Adobe Paragraph Composer (for Middle East languages, ...)
6 : Global Adobe Single-line Composer (for Middle East languages, ...)
7 : Adobe Linnaeus Composer
#include "internal/text.h"

v4.0.5 R12350, 1. Aug 2016

priint:comet InDesign® Plug-Ins

static int get_composer(
  ItemRef frameRef = 0,
  int pos = 0,
  int* len = 0)

Get the composer useed for a text paragraph.

Name Type Default Description
Return int   -1 : Error

1 : Adobe Paragraph Composer
2 : Adobe Single-line Composer
3 : Adobe Japanese Paragraph Composer
4 : Adobe Japanese Single-line Composer
5 : Global Adobe Paragraph Composer (for Middle East languages, ...)
6 : Global Adobe Single-line Composer (for Middle East languages, ...)
7 : Adobe Linnaeus Composer
Otherwise : Unknown
frameRef ItemRef 0 Valid text frame

0 : Current script frame
pos int 0 Text position
len int* 0 Number of letters using the same composer. Counted from pos.

0 : ignore
#include "internal/text.h"

v4.0.5 R12350, 1. Aug 2016

priint:comet InDesign® Plug-Ins

static int set_tatechuyoko(
  ItemRef frameRef = 0,
  int pos = 0,
  int len = 1,
  int state = 0,
  float xoffset = -1000000.0,
  float yoffset = -1000000.0)

Apply tate-chu-yokoto a given text range. Tate-chu-yoko is a (short) horizontal text inside a vertical text. Aer are tow screen shots of the effect:

   ⇒ 

Tate-chu-yoko can only applied on vertical text composed by the Adobe Japanese Paragraph Composer or Adobe Japanese Single-line Composer.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef 0 Valid text frames

0 : current script frame
pos int 0 Text position
len int 0 Number of letters to apply
state int 0 Set tate-chu-yoko?

0 : No
1 : Yes
x, y float, float -10000000.0, -1000000.0 Offset in points

<= -1000000.0 : ignore
#include "internal/text.h"
		
#include "internal/text.h"
int main ()
{
    int			len;
    float		x, y;
    int			tatechuyoko;
tatechuyoko = textmodel::get_tatechuyoko (gFrame, kSelection, &len, &x, &y); wlog ("", "tatechuyoko %d (%f %f) , %d more letters", tatechuyoko, x, y, len);
textmodel::set_tatechuyoko (gFrame, kSelection, -1, 1, 2.0, 3.0);
tatechuyoko = textmodel::get_tatechuyoko (gFrame, kSelection, &len, &x, &y); wlog ("", "tatechuyoko %d (%f %f) , %d more letters", tatechuyoko, x, y, len);
return 0; }

v4.0.5 R12350, 1. Aug 2016

priint:comet InDesign® Plug-Ins

static int get_tatechuyoko(
  ItemRef frameRef = 0,
  int pos = 0,
  int* len = 0,
  float* xoffset = 0,
  float* yoffset = 0)

Ask for tate-chu-yoko options, see set_tatechuyoko.

Tate-chu-yoko can only applied on vertical text composed by the Adobe Japanese Paragraph Composer or Adobe Japanese Single-line Composer.

Name Type Default Description
Return int   -1 : Error
0 : No
1 : Yes, horizontal text in vertical japanese text
frameRef ItemRef 0 Valid text frames

0 : current script frame
pos int 0 Text position
len int 0 Number of letters using the same tate-chu-yoko with the offsets. Counted from pos.

0 : ignore
x, y float*, float* 0, 0 Offset in points

0 : ignore
#include "internal/text.h"
		
#include "internal/text.h"
int main ()
{
    int			len;
    float		x, y;
    int			tatechuyoko;
tatechuyoko = textmodel::get_tatechuyoko (gFrame, kSelection, &len, &x, &y); wlog ("", "tatechuyoko %d (%f %f) , %d more letters", tatechuyoko, x, y, len);
textmodel::set_tatechuyoko (gFrame, kSelection, -1, 1, 2.0, 3.0);
tatechuyoko = textmodel::get_tatechuyoko (gFrame, kSelection, &len, &x, &y); wlog ("", "tatechuyoko %d (%f %f) , %d more letters", tatechuyoko, x, y, len);
return 0; }

v4.0.5 R12350, 1. Aug 2016

priint:comet InDesign® Plug-Ins
set_tatechuyoko

static int set_shatai(
  ItemRef frameRef = 0,
  int pos = 0,
  int len = -1,
  float magnification = 0.0,
  float angle = 45.0,
  int tsume = 0,
  int adjustRotation = 0)

Apply Shatai to text.

In traditional typesetting technology, characters were slanted by using a lens to distort the glyphs when being set on film. This oblique style is known as shatai. Shatai is distinct from a simple slant of the glyphs, because it also scales the glyphs. You can adjust the magnification or angle of text you want to slant from the center point, without changing the height of the glyph, using the shatai feature in InDesign®. (Adobe-Help)

Specify the following options to apply shatai:

Here is a screen shot:

A. No scale applied B. Magnification 30%, 45 shatai C. Selecting the Adjust Tsume option D. Selecting the Adjust Rotation option

Shatai can only applied on vertical text composed by the Adobe Japanese Paragraph Composer or Adobe Japanese Single-line Composer.

Name Type Default Description
Return int   0 or error rcode
frameRef ItemRef 0 Valid text frame

0 : Current script frame
pos int 0 Text position
len int kEnd Number of letters to apply
magnification int 0.0 see above
angle int 45.0 see above
tsume int 0 see above

0 : no
1 : yes
adjustRotation int 0 see above

0 : no
1 : yes
#include "internal/text.h"
		
#include "internal/text.h"
int main ()
{
    int			len;
    int			adjustRota, tsume;
    float		angle, magni;
textmodel::get_shatai (gFrame, kSelection, &len, &magni, &angle, &tsume, &adjustRota); wlog ("", "%d ::: %f, %f %d %d", len, magni, angle, tsume, adjustRota);
textmodel::set_shatai (gFrame, kSelection, -1, 30.0, 45.0, 0, 0);
textmodel::get_shatai (gFrame, kSelection, &len, &magni, &angle, &tsume, &adjustRota); wlog ("", "%d ::: %f, %f %d %d", len, magni, angle, tsume, adjustRota);
return 0; }

v4.0.5 R12350, 1. Aug 2016

priint:comet InDesign® Plug-Ins

static int get_shatai(
  ItemRef frameRef = 0,
  int pos = 0,
  int* len = 0,
  float* magnification = 0,
  float* angle = 0,
  int* tsume = 0,
  int* adjustRotation = 0)

Ask for shatai options, see set_shatai.

Shatai can only applied on vertical text composed by the Adobe Japanese Paragraph Composer or Adobe Japanese Single-line Composer.

Name Type Default Description
Return int   0 or error rcode
frameRef ItemRef 0 Valid text frame

0 : Current script frame
pos int 0 Text position
len int* 0 Number of letters, counted from pos, with same shatai options

0 : ignore
magnification int* 0 see set_shatai

0 : ignore
angle int* 0 see set_shatai

0 : ignore
tsume int* 0 see set_shatai

0 : ignore
adjustRotation int* 0 see set_shatai

0 : ignore
#include "internal/text.h"
		
#include "internal/text.h"
int main ()
{
    int			len;
    int			adjustRota, tsume;
    float		angle, magni;
textmodel::get_shatai (gFrame, kSelection, &len, &magni, &angle, &tsume, &adjustRota); wlog ("", "%d ::: %f, %f %d %d", len, magni, angle, tsume, adjustRota);
textmodel::set_shatai (gFrame, kSelection, -1, 30.0, 45.0, 0, 0);
textmodel::get_shatai (gFrame, kSelection, &len, &magni, &angle, &tsume, &adjustRota); wlog ("", "%d ::: %f, %f %d %d", len, magni, angle, tsume, adjustRota);
return 0; }

v4.0.5 R12350, 1. Aug 2016

priint:comet InDesign® Plug-Ins
set_shatai

static int set_warichu(
  ItemRef frameRef = 0,
  int pos = 0,
  int len = -1,
  int state = 0,
  int numLines = 2,
  float relativeSize = 0.5,
  float lineSpacing = 0.0,
  int alignment = 0,
  int minCharsBeforeBreak = 2,
  int minCharsAfterBreak = 2,
  int resizeParent = 0)

Apply warichu. The Warichu option in the Character panel decreases the typeface size of selected text to a percentage of the original and stacks the type—horizontally or vertically, according to the orientation—on multiple lines. Here is a screenshot of a warichu made this the options from the example:

\ SRC="../Images/warichu.png" ALIGN="middle" BORDER="0">

Warichu can only applied on vertical text composed by the Adobe Japanese Paragraph Composer or Adobe Japanese Single-line Composer.

Name Type Default Description
Return int   0 or error rcode
frameRef ItemRef 0 Valid text frame

0 : Current script frame
pos int 0 Text position
len int kEnd Number of letters to apply the warichu to
numLines int 2 Number of lines
relativeSize float 0.5 Relative text size in percent, 1.0 für 100%
lineSpacing float 0.0 Line spacing in points
alignment int 0 Text alignment :

kLeft
kCenter
kRight
kJustify
kJustifyLeft
kJustifyCenter
kJustifyRight
kJustifyAuto
kJustifyToBinding
kJustifyAwayBinding
minCharsBeforeBreak int 2 Minimum number of letters before line breaks
minCharsAfterBreak int 2 Minimum number of letters after line breaks
resizeParent int 0 -
#include "internal/text.h"
#include "internal/text.h"
int main () { int len; int state, lines, align, charsBefore, charsAfter, resizeParent; float sz, spacing;
textmodel::set_warichu (gFrame, kSelection, -1,   1,   3,   0.3,   3.0,   1,   3, 3,   0);
textmodel::get_warichu (gFrame, kSelection, &len,   &state,   &lines,   &sz,   &spacing,   &align,   &charsBefore, &charsAfter,   &resizeParent); wlog ("", "warichu ... %d : %d, %d, %f, %f, %d, %d, %d, %d\n", len,   state,   lines,   sz,   spacing,   align,   charsBefore, charsAfter,   resizeParent);
return 0; }

v4.0.5 R12350, 1. Aug 2016

priint:comet InDesign® Plug-Ins
get_warichu

static int get_warichu(
  ItemRef frameRef = 0,
  int pos = 0,
  int* len = 0,
  int* state = 0,
  int* numLines = 0,
  float* relativeSize = 0,
  float* lineSpacing = 0,
  int* alignment = 0,
  int* minCharsBeforeBreak = 0,
  int* minCharsAfterBreak = 0,
  int* resizeParent = 0)

Ask for warichu settings, see set_warichu.

Name Type Default Description
Return int   0 or ErrorCode
frameRef ItemRef 0 Valid text frame

0 : Current script frame
pos int 0 Text position
len int* 0 Number of letters, counted from pos, with same warichu options

0 : ignore
numLines int* 0 see set_warichu

0 : ignore
relativeSize float* 0 see set_warichu

0 : ignore
lineSpacing float* 0 see set_warichu

0 : ignore
alignment int* 0 see set_warichu

0 : ignore
minCharsBeforeBreak int* 0 see set_warichu

0 : ignore
minCharsAfterBreak int* 0 see set_warichu

0 : ignore
resizeParent int* 0 see set_warichu

0 : ignore
#include "internal/text.h"
#include "internal/text.h"
int main () { int len; int state, lines, align, charsBefore, charsAfter, resizeParent; float sz, spacing;
textmodel::set_warichu (gFrame, kSelection, -1,   1,   3,   0.3,   3.0,   1,   3, 3,   0);
textmodel::get_warichu (gFrame, kSelection, &len,   &state,   &lines,   &sz,   &spacing,   &align,   &charsBefore, &charsAfter,   &resizeParent); wlog ("", "warichu ... %d : %d, %d, %f, %f, %d, %d, %d, %d\n", len,   state,   lines,   sz,   spacing,   align,   charsBefore, charsAfter,   resizeParent);
return 0; }

v4.0.5 R12350, 1. Aug 2016

priint:comet InDesign® Plug-Ins

Although only appropriately localized versions of InDesign® offer the ability to set left-handed documents and text such as Arabic or Hebrew, any version of InDesign® can still handle right-to-left text.

Here are three ways to change the page binding in a 'normal' documents:

  1. Parameter bindingDirection of function document::create
  2. [since v4.3 R34060] Menue Font -> Page Binding
  3. Javascript
    app.documents[0].documentPreferences.pageBinding = PageBindingOptions.RIGHT_TO_LEFT; // LEFT_TO_RIGHT

    If you copy this line to a file with the extension jsx and save this file in the cscripts folder of your desktop, you can execute this command via the FrontRow panel.

Please note: The priint:comet plugins were developed for the 'normal' InDesign versions. We cannot guarantee that all priint:comet functionalities will also work with this different ME versions. Please understand that errors occurring due to changed page bindings will not be treated as bugs by our support but as (possible chargeable) feature requests.

Here are four how to create text that runs from right to left even in a 'normal' InDesign:®

  1. Execute the menu command Font -> Fill with Placeholder Text while holding down the CMD key. In the dialog that appears, you can select Arabic or Hebrew.
  2. Use the priint:comet Menü Font -> Text Orientation -> Right - Left to make the paragraph of the current text selection running from right to left.
  3. Import TaggedText with the following information (but of course without the line separators, which serve for the better clarity here only):
    <pTextComposer:HL Composer Optyca>
    <pTextAlignment:Right>
    <cLanguage:Arabic>
    <cKentenFont:Adobe Arabic>
    <cBoutenFontVariant:Regular>
    

    The letter order of the text contents in the TaggedText is as usual from left to right and is only reversed by the text composer later in the document!

  4. Using the following lines you can easily do this in cScript too:
    textmodel::set_attr (gFrame, 0, -1, kTextAttrComposerBoss, 0x2000 + 120);
    textmodel::set_attr (gFrame, 0, -1, kTextAttrAlignmentBoss, 2);
    textmodel::set_attr (gFrame, 0, -1, kTextAttrLanguageBoss, "Arabic");
    textmodel::set_attr (gFrame, 0, -1, kTAKentenFontFamilyBoss, "Adobe Aabric");
    textmodel::set_attr (gFrame, 0, -1, kTAKentenFontStyleBoss, "Regular");
    

Please note that the direction from right to left is only applied to letters that belong to a left-leaning language. All other letters retain their original running direction. So if you invert a text that contains only Latin characters, you will not see anything of the the changed direction at first. Only after entering Arabic or Hebrew characters you will see a change.

#include "internal/text.h"

Paul Seidel
12.03.2024, 15:56 Uhr
Plugin Version 1.0.10

Alphabetic index HTML hierarchy of classes or Java