Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created January 30, 2023 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/3b7183f9c5f269996e96c02615160931 to your computer and use it in GitHub Desktop.
Save bjoerntx/3b7183f9c5f269996e96c02615160931 to your computer and use it in GitHub Desktop.
function jsInsertTable(rows, cols, id) {
TXTextControl.tables.add(rows, cols, id, function(e) {
if (e === true) { // if added
TXTextControl.tables.getItem(function(table) {
table.cells.forEach(function(cell) {
cell.setText("Cell text");
});
}, null, 10);
}
})
}
function jsAddMergeField(text, name) {
TXTextControl.applicationFields.add(
TXTextControl.ApplicationFieldFormat.MSWord,
"MERGEFIELD",
text,
[name],
af => {
var highlightColor = "rgba(9, 165, 2, 0.3)";
var highlightMode = TXTextControl.HighlightMode.Always;
af.setHighlightColor(highlightColor);
af.setHighlightMode(highlightMode);
af.setDoubledInputPosition(true);
}
);
}
function jsSetMergeFieldText(text) {
TXTextControl.applicationFields.forEach(function(appField) {
appField.setText(text);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment