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

Anybody use PostScript with Adobe scripting workflows?

Valorous Hero ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

I took a look at PostScript, and it appears to be able to create files dynamically so that a tiny PS file can yield a very big and robust PDF file.

 

%!PS
/B {bind} bind def
/D {def} def
/Q {bind def} B D
/E {exch def} Q
/S {gsave} Q
/R {grestore} Q
/P 20 D
/N P 1 sub D
/I 1 P div D
initclip clippath pathbbox newpath
72 sub /URy E 72 sub /URx E 72 add /LLy E 72 add /LLx E
/Sq5 5 sqrt D
/F 2 Sq5 add D
/Wx URx LLx sub D /Wy URy LLy sub D
/Xx Wx 4 div D /Xy Wy F div D /X Xx Xy le {Xx}{Xy}ifelse D
Wx X 4 mul sub 2 div LLx add X 2 mul add Wy X F mul sub 2 div LLy add translate
/X X Sq5 mul D
X dup scale
0.1 X div setlinewidth
S
[ 1 .5 0 1 0 0 ] concat
0 1 N {I mul /A E
	0 1 N {I mul /B E
		S A B translate
		newpath 0 0 moveto I 0 rlineto 0 I rlineto I neg 0 rlineto
			closepath
		S I B add 1 1 A sub setrgbcolor fill R stroke % Green
		R
	      } for
      } for
R
S
[ -1 .5 0 1 0 0 ] concat
0 1 N {I mul /A E
	0 1 N {I mul /B E
		S A B translate
		newpath 0 0 moveto I 0 rlineto 0 I rlineto I neg 0 rlineto
			closepath
		S I B add 1 A sub 1 setrgbcolor fill R stroke % Blue
		R
	      } for
      } for
R
S
[ 1 .5 -1 0.5 0 1 ] concat
0 1 N {I mul /A E
	0 1 N {I mul /B E
		S A B translate
		newpath 0 0 moveto I 0 rlineto 0 I rlineto I neg 0 rlineto
			closepath
		S 1 1 B sub 1 A sub setrgbcolor fill R stroke % Red
		R
	      } for
      } for
R
showpage

 

This code which is the entirety of the sample PS file creates this all-vector PDF:

Silly-V_0-1608047638177.png

 

So it seems a workflow with a PS template could be used in a scripting workflow in some cases, also you'd have to be able to use Distiller or something else via cli commands.

But, is this a dead language, is it going to be deprecated and discarded one day? It seems quite useful, and quite stable as it is ancient, as opposed to some aspecs of Illustrator extensibility.

TOPICS
Scripting

Views

241

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 2 Correct answers

Community Expert , Dec 15, 2020 Dec 15, 2020

many years ago, I saw an ai script in a Russian forum use PS to create a file on the fly to either apply a Graphic Style or an Effect. I don't remember, but I found it fascinating. I was thinking on using it as well but never got a chance to play with it, the to-do list keeps growing.

 

good job on that snippet!

Votes

Translate

Translate
Engaged , Dec 15, 2020 Dec 15, 2020

PostScript drives most laser printers so I doubt it’s going away anytime soon. Yes it’s a full blown programming language so you can in principle hand-code all sorts of graphics rendering programs in it (e.g. BWIPP). Whether you’d choose to is another question: PS is relatively low-level, concerned purely with drawing, with no understanding of higher-level concepts as text frames or Unicode. For anything non-trivial it’s a lot of work, which is why PostScript code is usually written by other pro

...

Votes

Translate

Translate
Adobe
Community Expert ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

many years ago, I saw an ai script in a Russian forum use PS to create a file on the fly to either apply a Graphic Style or an Effect. I don't remember, but I found it fascinating. I was thinking on using it as well but never got a chance to play with it, the to-do list keeps growing.

 

good job on that snippet!

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
Engaged ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

LATEST

PostScript drives most laser printers so I doubt it’s going away anytime soon. Yes it’s a full blown programming language so you can in principle hand-code all sorts of graphics rendering programs in it (e.g. BWIPP). Whether you’d choose to is another question: PS is relatively low-level, concerned purely with drawing, with no understanding of higher-level concepts as text frames or Unicode. For anything non-trivial it’s a lot of work, which is why PostScript code is usually written by other programs. I can’t think of a compelling use case where you’d want to use it directly over higher-level drawing tools such as AI or Processing, modern PDF rendering libraries, or specialized high-level language such as TeX.

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