Copy link to clipboard
Copied
I have a table in which I want to use the "keep with next row" feature. However, I am using DITA, and so the "keep with row" property that is nominally available with FM is not saved with the .DITA file. How do I do this?
My attempt:
I know how to modify my EDD files to define choices for outputclass attribute of a table row (i.e. create a new choice "keep with next row" so that the author can select this option when editing). I also know how to add context rules to the EDD to be able to change the style/formatting based on a particular choice of outputclass (i.e. so that the PDF rendering uses a different format/style). What I am not sure how to do is define a style/format for a table row that would "keep with next", because the "keep with next" property is not part of the Table designer.
Q1: Is my approach possible, and if so how would I do it?
Q2: Is there another approach that would work and allow an author to "simply" select/indicate that a particular row should be kept with next?
Note: I am aware of the solution proposed by @frameexpert in https://community.adobe.com/t5/framemaker-discussions/is-it-possible-to-group-rows-of-a-table-and-th.... I was able to get that solution to "work", but it is not a super-user-friendly solution for the authors I work with because I could only make the column "invisible" by manually opening the .DITA file in Notepad++ and manually editing the colspec attribute: colwidth="0.1". I would prefer that the authors can do everything they need in FM.
This 5-minute video will answer your questions.
Copy link to clipboard
Copied
You could have the DITA authors set an outputclass attribute value of, say for instance, "keep-with-next" on those rows. However, you can't use the EDD to automatically set the row format to Keep With Next Row, based on the attribute value. You would need a script that would look for this outputclass value and programmatically set the property on the table row. The script would be relatively straightforward.
Copy link to clipboard
Copied
Thanks. I will have to ponder the script approach.
Having started to play with the invisible column approach, it does have some advantages (i.e. explicitly organizing a group of rows). However, I also discovered that I did not fully/properly test this approach. It turns out that when a .DITA file is opened and saved, it will auto-magically change colwidth="0.1" to colwidth="0*", which creates a rather wide/visible column. So as long as I do not save the .DITA file, the colwidth="0.1" will be kept (and used), which is a bit awkward. colwidth="1*" is kept, but that is still visible.
Any other suggestions on how to make a column in a table invisible? Or does that also require a script?
Copy link to clipboard
Copied
You can apply a Condition Format to a table column, then hide the Condition.
Copy link to clipboard
Copied
Thanks. I was starting to look up how to do that, but then realized I should confirm a couple of things:
Copy link to clipboard
Copied
This 5-minute video will answer your questions.
Copy link to clipboard
Copied
That was very insightful.
While I can show/hide the column using this method while editing, the extra column always appears in my generated PDF. I have looked at the output template that was imported into my .STS file (i.e. for Chapter Output) and it has the "DITA-Comment" tag in the Hide column. Any quick guesses on what is going on?
(NOTE: My console shows the following errors when generating a PDF, and has always done so:
"Show/Hide setting for DITA-Comment is inconsistent.")
Copy link to clipboard
Copied
How are you producing your PDF?
Copy link to clipboard
Copied
I select Publish > PDF
I have tried both FM2020 (16.0.4) and FM2022 (17.0.4).
I have tried both my .STS file (see below) and the default .STS file.
In all cases the column appears in the PDF, while it is
Copy link to clipboard
Copied
You have to figure out which template FrameMaker is using for the PDF and make sure the condition is hidden in that template. That's probably the subject of a new post.
Copy link to clipboard
Copied
Here is a teaser script that will allow you to use DITA markup to control Keep With Next Row setting. Follow these steps to set it up:
#target framemaker
main ();
function main () {
var doc, element;
doc = app.ActiveDoc;
if (doc.ObjectValid () === 1) {
// Make sure the document is structured.
element = doc.MainFlowInDoc.HighestLevelElement;
if (element.ObjectValid () === 1) {
processDoc (doc, element);
}
}
}
function processDoc (doc, element) {
var tbls, count, i;
if (app.Displaying === 1) {
app.Displaying = 0;
}
// Get all of the tables in the document's main flow.
tbls = getMainFlowTables (doc);
// Process each table.
count = tbls.length;
for (i = 0; i < count; i += 1) {
processTbl (tbls[i], doc);
}
if (app.Displaying === 0) {
app.Displaying = 1;
doc.Rehyphenate ();
doc.Redisplay ();
}
}
function processTbl (tbl, doc) {
var row, element, value;
// Loop through the rows in the table.
row = tbl.FirstRowInTbl;
while (row.ObjectValid () === 1) {
// Get the row element of the row object.
element = row.Element;
value = getAttributeValue (element, "outputclass");
if ((value) && (value === "keep-next")) {
row.RowKeepWithNext = 1;
}
else {
row.RowKeepWithNext = 0;
}
row = row.NextRowInTbl;
}
}
function getMainFlowTables (doc) {
var tbls, textList, count, i;
// Make an array for the table objects.
tbls = [];
// Get all the table text items from the main flow of the document.
textList = doc.MainFlowInDoc.GetText (Constants.FTI_TblAnchor);
count = textList.length;
// Add each Tbl object to the array.
for (i = 0; i < count; i += 1) {
tbls.push (textList[i].obj);
}
// Return the array.
return tbls;
}
function getAttributeValue (element, name) {
var attrList, count, i;
attrList = element.Attributes;
count = attrList.length;
for (i = 0; i < count; i += 1) {
if (attrList[i].name === name) {
if (attrList[i].values[0] !== undefined) {
return (attrList[i].values[0]);
}
}
}
}
Why do I call it a teaser script?
Copy link to clipboard
Copied
This was the answer I was hoping that was marked correct. Here is a video about a free script that you try:
Copy link to clipboard
Copied
@frameexpertsorry! I think these are both good answers. I selected the other answer for two reason:
- I have not used any scripts with FM before
- the other solution can solve other, related problems as well
So for anyone else reading his - please look at both answers!
Copy link to clipboard
Copied
No problem, I was just be facetious. It gave me a chance to write a useful script.