Copy link to clipboard
Copied
Hi,
Please, to start see the simple code that I'm writing:
var myDoc = app.activeDocument;
var myTable = app.selection[0].convertToTable("\t", "\t", 2);
myTable.cells[0].properties = {
contents: "TITLE",
width: "4 mm",
rotationAngle: 270,
rightInset: 0.5, leftInset: 0.5, topInset: 2, bottomInset: 2,
fillColor: "COLOR 2018",
bottomEdgeStrokeColor: "COLOR 2018",
topEdgeStrokeColor: "COLOR 2018",
leftEdgeStrokeColor: "COLOR 2018",
topEdgeStrokeWeight: 1,
bottomEdgeStrokeWeight: 1,
rightEdgeStrokeWeight: 0,
leftEdgeStrokeWeight: 1,
};
myTable.cells[0].texts[0].properties = {justification: Justification.RIGHT_ALIGN, appliedFont: "Fira Sans", fillColor: "Paper"};
myTable.cells[1].properties = {
width: "100 mm",
rightInset: 2, leftInset: 2, topInset: 2, bottomInset: 2,
bottomEdgeStrokeColor: "COLOR 2018",
topEdgeStrokeColor: "COLOR 2018",
topEdgeStrokeWeight: 1,
bottomEdgeStrokeWeight: 1,
rightEdgeStrokeWeight: 0,
leftEdgeStrokeWeight: 0,
};
myTable.cells[1].paragraphs[0].remove();
With that I'm change this:
To this:
Easy, ok?
So I get stuck with some things that I call for your help:
I hope you will understand what I want and I'm grateful for some help!
Hi,
Question 2:
Your table has a frame's (paragraph TTYTT) width while created by default. Store this value before setting custom width and calculate column width using this as a base.
Question 3:
to find current doc color name collect all collor name in an array and use a trick to match.Something like:
...var
mDoc,
mNames = mDoc.swatches.everyItem().name,
mString = "@@" + mNames.join("@@") + "@@", // so we've got a string "@@name1@@name2@@....@@"
foundName = mString.match(/[^@]+?2018(?=@@
Copy link to clipboard
Copied
Hi,
The question 1 is solved, is fontStyle instead fontStyleName, my mistake..
Copy link to clipboard
Copied
Hi,
Question 2:
Your table has a frame's (paragraph TTYTT) width while created by default. Store this value before setting custom width and calculate column width using this as a base.
Question 3:
to find current doc color name collect all collor name in an array and use a trick to match.Something like:
var
mDoc,
mNames = mDoc.swatches.everyItem().name,
mString = "@@" + mNames.join("@@") + "@@", // so we've got a string "@@name1@@name2@@....@@"
foundName = mString.match(/[^@]+?2018(?=@@)/),
foundColor = foundName ? mDoc.swatches.item(foundName[0]) : false;
if (!foundColor) alert ("Color '....2018' not found in a doc: " + mDoc.name);
So var foundColor is false or a color object ready to apply
Jarek
Copy link to clipboard
Copied
Thank you so much Jarek!
Copy link to clipboard
Copied
hi Jarek,
if it is possible to explain to me line 06
appreciating your response
Copy link to clipboard
Copied
Hi,
This is a shorter way to conditional assigning a value.
variable = condition ? valueIfTrue : valueIfFalse;
foundName could be an Array with string matched (true) or null (false).
Jarek
Copy link to clipboard
Copied
thank very,
it adds valuable knowledge to me.
may you suggested for me further reading about conditional assigning a value.