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

Help with some questions about tables, colors and fonts

Participant ,
Aug 11, 2017 Aug 11, 2017

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:

Captura de Tela 2017-08-11 às 08.46.11.png

To this:

Captura de Tela 2017-08-11 às 08.46.35.png

Easy, ok?

So I get stuck with some things that I call for your help:

  1. I'm applying the Fira Sans font in the word TITLE, but how I can use your style "Bold"? I know that's using the fontStyleName property but where?
  2. The width of my cells[1] is 100 mm, but I want this width the same size of the text frame. See the second image.
  3. I think this is the hard one! I'm using the color with name "COLOR 2018", but I will have different indesign files with different name colors. The only things that remains is the " 2018", like "BIO 2018", "MATH 2018". So is even possible to create a variable that apply the color using something like NAME + " 2018" instead the string itself?

I hope you will understand what I want and I'm grateful for some help!

TOPICS
Scripting

Views

612

Translate

Translate

Report

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

correct answers 1 Correct answer

Mentor , Aug 14, 2017 Aug 14, 2017

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(?=@@

...

Votes

Translate

Translate
Participant ,
Aug 14, 2017 Aug 14, 2017

Copy link to clipboard

Copied

Hi,

The question 1 is solved, is fontStyle instead fontStyleName, my mistake..

Votes

Translate

Translate

Report

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
Mentor ,
Aug 14, 2017 Aug 14, 2017

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

Votes

Translate

Translate

Report

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
Participant ,
Aug 14, 2017 Aug 14, 2017

Copy link to clipboard

Copied

Thank you so much Jarek!

Votes

Translate

Translate

Report

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
Community Beginner ,
Aug 22, 2017 Aug 22, 2017

Copy link to clipboard

Copied

hi Jarek,

if it is possible to explain to me line 06

appreciating your response

Votes

Translate

Translate

Report

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
Mentor ,
Aug 22, 2017 Aug 22, 2017

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

Votes

Translate

Translate

Report

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
Community Beginner ,
Aug 22, 2017 Aug 22, 2017

Copy link to clipboard

Copied

LATEST

thank very,

it adds valuable knowledge to me.  

may you suggested for me further reading about conditional assigning a value.

Votes

Translate

Translate

Report

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