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

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

Explorer ,
Jul 23, 2015 Jul 23, 2015

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.

TOPICS
Actions and scripting
1.4K
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
Adobe
Participant ,
Jul 25, 2015 Jul 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

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 ,
Jul 26, 2015 Jul 26, 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?

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 ,
Jul 27, 2015 Jul 27, 2015
LATEST
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