Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

InDesign server queue gets quit while merging table cells

Engaged ,
Dec 26, 2021 Dec 26, 2021

Hi All,

 

I have a function call 'addHeaderRowContinue' and this is running ok on desktop version of indesign but when I run on InDesign CC 2017 server queue gets quit at below line: 

 

table.cells.itemByRange(startIndex.join(":"), endIndex.join(":")).merge();

 

Below is the complete function. Can anyone help me out from this?

 

function addHeaderRowContinue(table) {
    var counter, row, headerRowCount, cellCounter, cell, column, newRow, startIndex, endIndex, newCell, tableTitleElement, elementCounter;
    try {
        headerRowCount = 0;
        for (counter = 0; counter < table.rows.length; counter++) {
            try {
                if ((row = table.rows[counter]).cells[0].associatedXMLElement.markupTag.name.match(/(tabletitle|tch)/i)) {
                    headerRowCount++;
                }
                else break;
            }
            catch (e) {
                generateLog(e);
            }
        }
        myDoc.recompose();
        for (counter = headerRowCount - 1; counter >= 0; counter--) {
            try {
                row = table.rows[counter];
                newRow = table.rows.add(LocationOptions.AFTER, table.rows[headerRowCount - 1]);
                newRow.cells.everyItem().unmerge();
            }
            catch (e) {
                generateLog(e);
            }
        }
        myDoc.recompose();
        for (counter = 0; counter < headerRowCount; counter++) {
            try {
                row = table.rows[counter];
                newRow = table.rows[counter + headerRowCount];
                for (cellCounter = 0; cellCounter < row.cells.length; cellCounter++) {
                    try {
                        cell = row.cells[cellCounter];
                        if (cell.columnSpan > 1 || cell.rowSpan > 1) {
                            var startIndex = newRow.cells[cellCounter].cells[0].name.split(":");
                            var endIndex = [];
                            endIndex[0] = (+startIndex[0]) + cell.columnSpan - 1;
                            endIndex[1] = (+startIndex[1]) + cell.rowSpan - 1;
                            table.cells.itemByRange(startIndex.join(":"), endIndex.join(":")).merge();
                        }
                        cell.texts[0].duplicate(LocationOptions.AT_BEGINNING, newCell);
                        myDoc.recompose();
                    }
                    catch (e) {
                        generateLog(e);
                    }
                }
            }
            catch (e) {
                generateLog(e);
            }
        }
        table.rows.itemByRange(0, headerRowCount - 1).rowType = RowTypes.HEADER_ROW;
        table.breakHeaders = HeaderFooterBreakTypes.ONCE_PER_PAGE;
        table.skipFirstHeader = true;
    }
    catch (e) {
        generateLog(e);
    }
}

 

 

Regards

-Sumit
TOPICS
Bug , Scripting , SDK
152
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation