Skip navigation
Currently Being Moderated

use bridge to create text layer which contains special characters

Aug 7, 2012 12:32 AM

Hi,guys.

I want create a psd using bridge. but failed. Can anyone help me?

 

here is my script:

 

 

script2 = 'var docWidth = 1650;';

script2 +='var docHeight = 1650;';

script2 +="var docName ='Front';";

script2 +='var docRef = app.documents.add(docWidth,docHeight, 300,docName);';

script2 +="var myLayer1 = docRef.artLayers.add();";

script2 +="myLayer1.kind = LayerKind.TEXT;";

script2 +="myLayer1.textItem.kind = TextType.POINTTEXT;";

script2 +="myLayer1.textItem.font='News702 BT';";

script2 +="myLayer1.textItem.size=13;";

script2 +="var textColor1 = new SolidColor;";

script2 +="textColor1.rgb.hexValue = 'F8F3E9';";

script2 +="myLayer1.textItem.color = textColor1;";

script2 +="myLayer1.textItem.contents = 'abcd\'abd\'ed\"afa\"';";      

var bt = new BridgeTalk();

bt.target = "photoshop";

bt.body = script2;

bt.send();

the problem is the text content contains ' or ".

 
Replies
  • Currently Being Moderated
    Aug 7, 2012 1:32 AM   in reply to michael.shen

    You have a few problems with your script, you are giving values for the width and height for the new document and they will default the ruler unit setting you have in Photoshop, this may not be pixels.

    The font name should be the postScript name and they do not contain spaces.

    It is best to pass an encoded string to the script and then decode it in Photoshop IE:-

     

     

    var text = encodeURI('abcd\'abd\'ed\"afa');
    var bt = new BridgeTalk();
    bt.target = "photoshop";
    bt.body = bt.body = "var main = " + script.toSource() + "; main(" + text.toSource() + ");";
    bt.send(4);
     
    function script(text){
    var docWidth = 1650;
    var docHeight = 1650;
    var docName ='Front';
    var docRef = app.documents.add(new UnitValue(docWidth,'px'),new UnitValue(docHeight,'px'), 300,docName);
    var myLayer1 = docRef.artLayers.add();
    myLayer1.kind = LayerKind.TEXT;
    myLayer1.textItem.kind = TextType.POINTTEXT;
    myLayer1.textItem.font='Georgia';
    myLayer1.textItem.size=13;
    var textColor1 = new SolidColor;
    textColor1.rgb.hexValue = 'F8F3E9';
    myLayer1.textItem.color = textColor1;
    myLayer1.textItem.contents =decodeURI(text);
    }
    
    
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points