POSTSCRIPT(oh) LOCAL POSTSCRIPT(oh) postscript - usage, macros, tips and examples. PostScript is a stack-based documentation language. BASICS Document processor : %!PS or %!PS-Adobe Using %!Ps-Adobe allows PDF viewers to show document properties. Tested properties: %%Title , %%Creator Device parameters : setpagedevice Example: /PageSize << /PageSize [ width height ] >> setpagedevice Set position : x y moveto position 0 0 moveto is bottom left. Set font : /fontName fontSize selectfont Fonts tested: Helvetica, Courier, Times, Palatino. All tested fonts have variants: -Bold, -Oblique, -BoldOblique. Eg.: /Helvetica-Bold Display text : (Text) show Show content : showpage Example %!PS-Adobe %%Title: The practice document %%Creator: the ps creator << /PageSize [792 612] >> setpagedevice 10 580 moveto /Helvetica-Bold 12 selectfont (Text in Helvetica-Bold) show 10 560 moveto /Helvetica 12 selectfont (Text in Helvetica) show 10 545 moveto /Courier 12 selectfont (Text in Courier) show showpage Result: Text in Helvetica-Bold Text in Helvetica Text in Courier The example can be saved and exported to PDF: ps2pdf PS_FILE PDF_FILE BASIC MACROS Macros are defined as /MacroName MacroContent def or /MacroName { MacroContent } def . Store page size: /pageWidth 792 def /pageHeight 612 def << /PageSize [pageWidth PageHeight] >> setpagedevice Letter is 612x792, A4 is 595x843, can be inverted to use in portrait or landscape. selectfont function: /fontSize 12 def /selFont { fontSize selectfont } def /font /Helvetica selFont def selFont STACK PostScript is a stack-based language, eg.: 2 3 add returns 5, 5 2 sub returns 3. COMMANDS Return current x and y : currentpoint Exchange the top two values from the stack : exch Return the top value from the stack : pop Sum top two values : add Sub top value from previous value : sub Multiply top two values : mul Divide the previous to last value by the top value : div Usage Set new y position /margin_left 10 def /line_height 15 def /cur_y { currentpoint exch pop line_height sub } def /new_line { margin_left cur_y moveto } def 1. Define margin_left as 10 2. Define line_height as 15 3. Get current x and y 4. Exchange x and y to have x as the top value in the stack. 5. Pop x out of the stack. 6. Remove line_height from current y position to get the new y position. 7. new_line: Move to x at margin_left and cur_y New text line /text_line { new_line /Helvetica sel_font show } def (line added with text_line) text_line TODO - Add sample file. SEE ALSO dc(oh) , latex(oh) , pdf(oh) , documentation(oh) - Archlinux manpages: ps2pdf(1) links - PLRM - PostScript Language Reference Manual: https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf - PostScript Language Tutorial and Cookbook: https://archive.org/details/postscriptlangua00adobrich - Thinking in PostScript: https://hint.userweb.mwn.de/compiler/ThinkingInPostScript.pdf - A First Guide to PostScript: http://www.tailrecursive.org/postscript/postscript.html AUTHORS ohazot(oh) | about(oh) | ohazot.com: https://ohazot.com linux , OpenBSD 7.8 | Created:2026-03-30|Updated:2026-03-30| POSTSCRIPT(oh)