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

It is possible to scale a batch of tables to a fixed percentage?

Engaged ,
Jan 11, 2021 Jan 11, 2021

Copy link to clipboard

Copied

This is an ID file with hundred of tables, one per page, unthreaded.

We need to rescale at 90%.

We need to place them in the layout as ID format to adjust them.

The idea of using a Pdf is not convenient...

 

Thanks.

TOPICS
How to

Views

330

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

Participant , Jan 12, 2021 Jan 12, 2021
var myDoc = app.activeDocument

var scaling = app.transformationMatrices.add()
scaling = scaling.scaleMatrix(0.9,0.9)

for ( var i = 0; i < myDoc.pages.length; i++ ){
    for ( var j = 0; j < myDoc.pages[i].textFrames.length; j++ ){
        //myDoc.pages[i].textFrames[j].tables.everyItem().width = desiredTableWidth;
        myDoc.pages[i].textFrames[j].transform(
            CoordinateSpaces.INNER_COORDINATES,
            AnchorPoint.TOP_LEFT_ANCHOR,
            scaling
        )
    }
}

 

If all

...

Votes

Translate

Translate
Participant ,
Jan 11, 2021 Jan 11, 2021

Copy link to clipboard

Copied

Hello @palala fog ,

 

From what I can see there isn't a way to set Table widths or cell width through a style. The only way that I could see to automate this would be to create a script that resizes all the tables.

 

Below is something I bashed out quickly. I only tested very quickly and it seems like it does the job.

 

var desiredTableWidth = 140;

var myDoc = app.activeDocument

for ( var i = 0; i < myDoc.pages.length; i++ ){
    for ( var j = 0; j < myDoc.pages[i].textFrames.length; j++ ){
        myDoc.pages[i].textFrames[j].tables.everyItem().width = desiredTableWidth;
    }
}

 

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
Engaged ,
Jan 12, 2021 Jan 12, 2021

Copy link to clipboard

Copied

hi,

 

first, thanks. your script is very interesting because it really scales the tables to a defined measure!

in this case, you propose 140 mm that maintains accurate font sizes and weight lines, for example.

 

here we need to reduce 90% the whole table because the book changed size and we need a smaller size.

 

it is possible to script this?

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 ,
Jan 12, 2021 Jan 12, 2021

Copy link to clipboard

Copied

Hello@palala fog ,

 

Do you need the fonts and the strokes scaled as well? are all tables the same size?

 

Technicaly we could have the script do everything but this is a lot more work to code something up. You could have a table style (with paragraph) handle the rescaling of fonts, strokes and padding.

 

Regards

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
Engaged ,
Jan 12, 2021 Jan 12, 2021

Copy link to clipboard

Copied

Hi, if I just select the table and reduce it 90% by menu, immediately the table gets a fine size (Body text changes from 9 to 8 pt, for example, better adapted to the smaller size of the document) and no matter at all the size.* I mean: the idea is to reduce the whole table as a unity. There are many sizes.

 

As we have 300 tables this manual procedure to resize them seems illogical.

 

Thanks

 

 

 

*Although your script is a very good piece to adapt tables to a defined length.

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 ,
Jan 12, 2021 Jan 12, 2021

Copy link to clipboard

Copied

var myDoc = app.activeDocument

var scaling = app.transformationMatrices.add()
scaling = scaling.scaleMatrix(0.9,0.9)

for ( var i = 0; i < myDoc.pages.length; i++ ){
    for ( var j = 0; j < myDoc.pages[i].textFrames.length; j++ ){
        //myDoc.pages[i].textFrames[j].tables.everyItem().width = desiredTableWidth;
        myDoc.pages[i].textFrames[j].transform(
            CoordinateSpaces.INNER_COORDINATES,
            AnchorPoint.TOP_LEFT_ANCHOR,
            scaling
        )
    }
}

 

If all you have is just tables then this scales every text frame to 90%.

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
Engaged ,
Jan 12, 2021 Jan 12, 2021

Copy link to clipboard

Copied

LATEST

Dear Tacoeater,

 

For the moment your script worked perfectly.

It worked really fantastic.

 

Thanks for your time and patience.

 

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