Skip to main content
Inspiring
July 24, 2015
Question

How to get the result of "Layer - Copy CSS" using script?

  • July 24, 2015
  • 1 reply
  • 1381 views

I'm working on a tool which converts a simple PSD file into HTML.

I'd like to use 2 layers to convert the text:

- A text layer to generate the text for HTML and font info for CSS;

- An optional shape layer to generate the border info for CSS.

Photoshop CS6 and later versions provide a Copy CSS feature, which is suitable for grabbing CSS border info from Live Shape layers. I've used ScriptListener and got the code to run this menu command. Now I'm wondering how do I get the CSS code from the system pasteboard?

I come up with 2 possible ways which I haven't tested yet.

1. Create a new text layer and call some commands to paste. Then I get the text info using the TextItem.contents property;

2. Use Adobe Generator to send a signal to the Node.js server. Then use child_process.exec provided by Node.js to run the Unix pbpaste command and pipe the output.

Does one of the methods work? Or is there a much easier way?

Thanks.

This topic has been closed for replies.

1 reply

uberplugins
Inspiring
July 25, 2015

It may be better to take a standard script from

C:\Program Files\Adobe\Adobe Photoshop CC 2015\Required\CopyCSSToClipboard.jsx


and get result from variables

kfitfkAuthor
Inspiring
July 27, 2015

I didn't find the CopyCSSToClipboard.jsx file on my Mac. I'm using Photoshop CC 2015.

I need to loop through the whole PSD document and run this CopyCSS command several times. The jsx script you mentioned above returns the value when it's done?

uberplugins
Inspiring
July 28, 2015