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

I want to break the text with a space character and turn it into a text column.

Explorer ,
Sep 11, 2018 Sep 11, 2018

Copy link to clipboard

Copied

This is the effect I want to achieve.

s

Because the text doesn't split, it's always hard to align. I always do this manually.

TOPICS
Actions and scripting

Views

1.5K

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

People's Champ , Sep 13, 2018 Sep 13, 2018

You could change the script yourself

if (app.preferences.rulerUnits == Units.PERCENT) app.preferences.rulerUnits = Units.CM;

app.activeDocument.suspendHistory("Text Columns", "main()") 

 

function main() 

    { 

    try { 

        var layer = activeDocument.activeLayer; 

 

        if (layer.kind != LayerKind.TEXT) { alert("Not a text"); return; } 

 

        layer.textItem.kind = TextType.POINTTEXT; 

     

        var text = layer.textItem.contents; 

     

        var lines = text.split("\r"); 

   

...

Votes

Translate

Translate
Adobe
Explorer ,
Sep 11, 2018 Sep 11, 2018

Copy link to clipboard

Copied

I tried to learn the script myself.

Although I recently bought a PS script from Davide Barranca

But my ability is not enough to complete, thank you to all who can help me.

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
LEGEND ,
Sep 11, 2018 Sep 11, 2018

Copy link to clipboard

Copied

What's the name of that script and where it can be purchased? Does Davide Barranca accept Alipay?

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
Explorer ,
Sep 11, 2018 Sep 11, 2018

Copy link to clipboard

Copied

PayPal registration in China is very troublesome

So we have to buy you things, they are looking for Taobao purchase, but they will handle the fee.

Davide Barranca's script book does not support Alipay. I found a purchase. I spent 700 RMB and spent 20 RMB, which is 2.9 US dollars. But his book is only in English. I am still trying to translate it.

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
Explorer ,
Sep 11, 2018 Sep 11, 2018

Copy link to clipboard

Copied

More than 20 RMB, 700 is almost my 7-day salary.

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
LEGEND ,
Sep 11, 2018 Sep 11, 2018

Copy link to clipboard

Copied

I didn't understand. What service you used then to buy his book. Whas that you named 'Taobao'? And how much you spent in fact. You say that was at same time 700 RMB and 20 RMB, so 720 RMB in sum? Anyway what you mean by 2.9 US dollars? I checked 700 RMB is about 100 US dollars, well?

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
Explorer ,
Sep 11, 2018 Sep 11, 2018

Copy link to clipboard

Copied

Helping the person who buys, I need to pay more for him.

Purchased people order through Taobao

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
Explorer ,
Sep 11, 2018 Sep 11, 2018

Copy link to clipboard

Copied

Many people use Taobao to help others purchase to get the intermediate fee.

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
Explorer ,
Sep 11, 2018 Sep 11, 2018

Copy link to clipboard

Copied

I didn't get this script. I just want to ask friends in the community to complete it. Script I haven't learned yet.

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
Explorer ,
Sep 11, 2018 Sep 11, 2018

Copy link to clipboard

Copied

Misunderstanding caused by inaccurate Google translation

His book is $99, equivalent to RMB 680.

Then the purchase will charge me 700 yuan

I have to give 20 yuan more to the person purchasing.

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
People's Champ ,
Sep 12, 2018 Sep 12, 2018

Copy link to clipboard

Copied

Untitled-1.png

No ?

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
Explorer ,
Sep 12, 2018 Sep 12, 2018

Copy link to clipboard

Copied

Alignment is not what I want

I want to split it into text columns to make it easier to edit text.

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
Explorer ,
Sep 12, 2018 Sep 12, 2018

Copy link to clipboard

Copied

上传2.gif

This is just 3 columns and it is difficult to align

Sometimes there are several columns of text that are more difficult to align. Usually I will split it into text segments so it's easier and more appropriate.

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
People's Champ ,
Sep 13, 2018 Sep 13, 2018

Copy link to clipboard

Copied

OK. I do not want to break text into several text layers. Do it yourself. But you can try this option

Create any multi-line text with a fixed number of words in a line separated by any number of spaces.

Run the script.

The script will turn the text into a multi-column paragraph text.

Then you can select any columns text and set the appropriate alignment and style for it.

To shift a particular column, use the paragraph parameters.

Untitled-2.png

app.activeDocument.suspendHistory("Text Columns", "main()")

function main()

    {

    try {

        var layer = activeDocument.activeLayer;

        if (layer.kind != LayerKind.TEXT) { alert("Not a text"); return; }

        layer.textItem.kind = TextType.POINTTEXT;

   

        var text = layer.textItem.contents;

   

        var lines = text.split("\r");

   

        var x = 0;

        for (var i = lines.length-1; i >= 0; i--) if (lines == "") ++x; else break;

        lines.length = lines.length - x

   

        var words = new Array()

   

        var clms_width = 0;

   

        var rows = lines.length;

        var clms;

        for (var i = 0; i < lines.length; i++)

            {

            lines = lines.replace(/^\s+/g, "");

            lines = lines.replace(/\s+$/g, "");

   

            lines = lines.replace(/\s+/g, " ");

   

            var w = lines.split(" ");

            if (!i) clms = w.length;

            else if (clms != w.length) { alert("Different number of columns detected"); return; }

   

            for (var n = 0; n < w.length; n++)

                {

                words[n*rows + i] = w;

   

                if (w.length > clms_width) clms_width = w.length;

                }

            }

        if (clms == 1) { alert("No columns detected"); return; }

   

        clms_width += 1;

   

        var text = "";

        var text0 = "";

   

        for (var i = 0; i < clms; i++)

            {

            for (var n = 0; n < clms_width; n++) text0 += "_"; // change "_" to a wider character if necessary

   

            if (i != clms-1) text0 += " ";

            }

   

        for (var i = 0; i < rows; i++)

            {       

            text += text0; if (i != rows-1) text += "\r";

            }

        layer.textItem.kind = TextType.POINTTEXT;

   

        layer.textItem.contents = text;

   

        layer.textItem.kind = TextType.PARAGRAPHTEXT

   

        var r = new ActionReference();   

        r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("textKey"));

        r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

   

        var data = executeActionGet(r).getObjectValue(stringIDToTypeID("textKey"));

   

        var sh = data.getList(stringIDToTypeID("textShape"));

        var s1 = sh.getObjectValue(0);

   

        s1.putInteger(stringIDToTypeID("rowCount"), 1)

        s1.putInteger(stringIDToTypeID("columnCount"), clms)

        s1.putBoolean(stringIDToTypeID("rowMajorOrder"), true);

   

        sh.clear()

        sh.putObject(stringIDToTypeID("textShape"), s1)

   

        data.putList(stringIDToTypeID("textShape"), sh)

   

        var r = new ActionReference();   

        r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

   

        var d = new ActionDescriptor();

        d.putReference(stringIDToTypeID("null"), r);

        d.putObject(stringIDToTypeID("to"), stringIDToTypeID("textKey"), data);

        executeAction(stringIDToTypeID("set"), d, DialogModes.NO);

   

        var text = "";

   

        for (var i = 0; i < words.length; i++)

            {

            text += words;

            if (i != words.length-1) text += "\r";

            }

        layer.textItem.contents = text;

        }

    catch(e) { alert(e); }

    }

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
Explorer ,
Sep 13, 2018 Sep 13, 2018

Copy link to clipboard

Copied

Thank you very much for the script though not what I want

Because I think splitting is easier to edit, more controllable

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
People's Champ ,
Sep 13, 2018 Sep 13, 2018

Copy link to clipboard

Copied

You could change the script yourself

if (app.preferences.rulerUnits == Units.PERCENT) app.preferences.rulerUnits = Units.CM;

app.activeDocument.suspendHistory("Text Columns", "main()") 

 

function main() 

    { 

    try { 

        var layer = activeDocument.activeLayer; 

 

        if (layer.kind != LayerKind.TEXT) { alert("Not a text"); return; } 

 

        layer.textItem.kind = TextType.POINTTEXT; 

     

        var text = layer.textItem.contents; 

     

        var lines = text.split("\r"); 

     

        var x = 0; 

        for (var i = lines.length-1; i >= 0; i--) if (lines == "") ++x; else break; 

        lines.length = lines.length - x 

     

        var words = new Array() 

     

        var rows = lines.length; 

        var clms; 

 

        for (var i = 0; i < lines.length; i++) 

            { 

            lines = lines.replace(/^\s+/g, ""); 

            lines = lines.replace(/\s+$/g, ""); 

     

            lines = lines.replace(/\s+/g, " "); 

     

            var w = lines.split(" "); 

 

            if (!i) clms = w.length; 

            else if (clms != w.length) { alert("Different number of columns detected"); return; } 

     

            for (var n = 0; n < w.length; n++)  

                words[n*rows + i] = w

            } 

 

        if (clms == 1) { alert("No columns detected"); return; } 

        var off = 0; // distance between columns

        var layer1 = layer;

        for (var i = 0; i < clms; i++) 

            {

            var layer2 = layer1.duplicate();

           

            var text = ""; 

         

            for (var n = i*rows; n < (i+1)*rows; n++) 

                { 

                text += words

                if (n != (i+1)*rows-1) text += "\r"; 

                } 

            layer2.textItem.contents = text; 

            if (i) layer2.translate(layer1.bounds[2]-layer2.bounds[0] + off);

            else   { layer2.translate(layer2.bounds[0]-layer1.bounds[0]); off = (layer2.bounds[2]-layer2.bounds[0])/5; }

            layer1 = null;

            layer1 = layer2;

            }

        layer.remove();

        } 

    catch(e) { alert(e); } 

    } 

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
Explorer ,
Sep 13, 2018 Sep 13, 2018

Copy link to clipboard

Copied

LATEST

Do you have Alipay? I want to buy you a cup of coffee. Thank you very much. I always wanted something like 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