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

can we set auto size property for text Frames through jsx ?

Participant ,
Oct 06, 2015 Oct 06, 2015

is it possible to set auto size property for text Frames through jsx. this option is present in Area type options dialog in illustartor.

To open dialog.

select a textFrame --> Type -->Area type Options. --> now can see property auto size checkbox.

Any help or suggestion will be appreciated,

Thanks ,

Upendra

TOPICS
Scripting
2.7K
Translate
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

Community Expert , Oct 08, 2015 Oct 08, 2015

We can set preference of auto sizing:

app.preferences.setBooleanPreference("text/autoSizing",

  !app.preferences.getBooleanPreference("text/autoSizing"));

You have to run script before adding tetFrames.

Translate
Adobe
Valorous Hero ,
Oct 06, 2015 Oct 06, 2015

I don't see a property like that in the OMV, but I do see that it is a recordable action. So, at least, you can record your action and have your script play it.

Translate
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 ,
Oct 06, 2015 Oct 06, 2015

i just want to turn on or off this auto size property through Jsx .

Translate
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
Guide ,
Oct 06, 2015 Oct 06, 2015

Silly is correct as far as I can see.

and the best way to deal with it will be via an action.

the action can be created, run and removed, all from the script.

I would be happy to help with this if you want.

I have to go collect the children now but will have a play with it tomorrow for you.

Translate
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 ,
Oct 06, 2015 Oct 06, 2015

ya sure Qwertyfly...‌ please go ahead . and let me know if some how possible.

Thanks

Translate
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
Guide ,
Oct 07, 2015 Oct 07, 2015

this could be harder then I first thought.

I assumed Silly-V had tested the Action-ability of the auto feature.

this feature was added to illustrator cc2014.

looks like adobe just stuffed it in with out integrating it in to Javascript, or actions.

one more short fall from the programming team.

we could set the frame to fit the text.

but that will not make it auto fit if you then edit the text.

I may need to know a bit more about what you are trying to achieve.

then we may be able to find another way around.

Is this just for you, or is it going to be run on other machines?

Are you on Mac or PC?

Is the text frame content formatted in a set and simple way?

or is it multi coloured and many sizes and styles?

Translate
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 ,
Oct 07, 2015 Oct 07, 2015

Hi Qwertyfly...‌

i'm a windows user but the plugin that i'm working on need to be supported at both mac and windows , this should get worked on other machines also,

what i want to achieve is to traverse through all the text Frames and toggle its auto size property like sometimes i do not need to auto size a single text frames for some reasons.

Text frame content is formatted in a simple way with single color.

Translate
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
Guide ,
Oct 07, 2015 Oct 07, 2015

it is simple enough to resize the text frame to fit the current content.

but I am not sure that is going to be what you want.

the only work around I can think of will be to:

for each textFrame get details like font size, colour, width, etc..

load contents to a variable.

then I need to get an existing text frame that has the auto feature set and duplicate that.

change all its setting to the original text frame and fill it with the contents we collected previously.

then we can remove the original frame.

just need to decide how to get the existing frame that has the auto feature already set.

this could be from a small file saved on the computer somewhere.

leave it with me and I'll see if I can get it to work.

this is just the spill over of my thought process, I'm having a hell of a day today and needed to put it in writing before it gets pushed out by the next thick client who wants to request 2000 pens printed 4 colours and delivered to some unknown country location by monday.

sorry about that, It does make me feel better to vent though...

Translate
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
Valorous Hero ,
Oct 08, 2015 Oct 08, 2015

I was able to record the action in CC 2015, maybe they didn't have it recordable in 2014 though.

Oh doy! That's right, it records a bunch of properties except the Auto-Size!  How lame!

Translate
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 Expert ,
Oct 08, 2015 Oct 08, 2015

We can set preference of auto sizing:

app.preferences.setBooleanPreference("text/autoSizing",

  !app.preferences.getBooleanPreference("text/autoSizing"));

You have to run script before adding tetFrames.

Translate
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
Guide ,
Oct 08, 2015 Oct 08, 2015

Nice work Ten A‌,

this will make it much simpler.

Translate
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
Guide ,
Oct 08, 2015 Oct 08, 2015

Here is my working example.

this should set all AreaText in document to auto size and keep the same width and position.

function setAutoTextFrames(){

    var autoSize = app.preferences.getBooleanPreference("text/autoSizing");

    app.preferences.setBooleanPreference("text/autoSizing", true); 

    var doc = app.activeDocument;

    var txt = doc.textFrames;

    var content;

    for(var i= txt.length-1; i>-1; i--){

        if(txt.kind == "TextType.AREATEXT"){

            content = txt.contents;

            txt.contents = "This is just a random string of text to keep the width of the text frame stable while we convert to point text then back to area text";

            txt.convertAreaObjectToPointObject();

            txt.convertPointObjectToAreaObject();

            txt.contents = content;

        }

    }

    app.preferences.setBooleanPreference("text/autoSizing", autoSize);

}

setAutoTextFrames();

if you text boxes are wider then the random string then make the random string longer...

Translate
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
Explorer ,
May 22, 2016 May 22, 2016

Super useful - thanks Qwertyfly.

Translate
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 ,
Oct 08, 2015 Oct 08, 2015

Nice work Ten A‌

Thank you so much , and also thanks to Qwertyfly...‌ you made it

Translate
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
Guide ,
Oct 08, 2015 Oct 08, 2015

no problem, I hope its a help.

I learnt a few things in the process.

cheers for the snippet Ten-A.

Translate
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
Explorer ,
Oct 26, 2023 Oct 26, 2023
LATEST

save my day, good job.

Translate
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