.Dd Created:2026-03-30|Updated:2026-03-30| .de ocsi \\$* , .. .de oxr .ocsi .Xr \\$* .. .de oit .It \\$* .. .de obdi .Bl -dash -compact .oit \\$* .. .de obdl .Bd -literal -compact \\$* .. .de onote .Bl -hang -compact .oit \\$* .El .. .de ocomm .Bl -diag -compact .oit \\$* .El .. .de opsy .Pp .Sy - \\$* .. .de obc .Bl -column \\$* .. .de obc2 .obc opt desc .. .de obc3 .obc option arguments description .. .nr r 0 .ie ( \nr == 1 ) \{\ .de dm .opsy OpenBSD manpages: \\$* .. .\} .ie ( \nr == 0 ) \{\ .de dm .opsy Archlinux manpages: \\$* .. .\} .Dt POSTSCRIPT oh .Os linux , OpenBSD 7.8 | .Nm postscript .Nd usage, macros, tips and examples. PostScript is a stack-based documentation language. .Sh BASICS .obc document_proces .It Document processor Ta : Li %!PS No or Li %!PS-Adobe .D1 Using Li %!Ps-Adobe No allows PDF viewers to show document properties. .D1 Tested properties: Li %%Title No , Li %%Creator .It Device parameters Ta : Li setpagedevice .D1 Example: .obdl /PageSize << /PageSize [ width height ] >> setpagedevice .Ed .It Set position Ta : Li x y moveto .D1 position Li 0 0 moveto No is bottom left. .It Set font Ta : Li /fontName fontSize selectfont .D1 Fonts tested: Li Helvetica, Courier, Times, Palatino. .D1 All tested fonts have variants : -Bold, -Oblique, -BoldOblique. Eg.: Li /Helvetica-Bold .It Display text Ta : Li (Text) show .It Show content Ta : Li showpage .El .Ss Example .obdl %!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 .Ed .Sy Result: .obc .It Sy Text in Helvetica-Bold .It Text in Helvetica .It Li Text in Courier .El The example can be saved and exported to PDF: .Dl ps2pdf PS_FILE PDF_FILE .Sh BASIC MACROS Macros are defined as .Li /MacroName MacroContent def or .Li /MacroName { MacroContent } def \&. .obc store_page_size .It Store page size: .obdl /pageWidth 792 def /pageHeight 612 def << /PageSize [pageWidth PageHeight] >> setpagedevice .Ed .D1 Letter is 612x792, A4 is 595x843, can be inverted to use in portrait or landscape. .It selectfont function: .obdl /fontSize 12 def /selFont { fontSize selectfont } def /font /Helvetica selFont def selFont .Ed .Sh STACK PostScript is a stack-based language, eg.: .Li 2 3 add returns 5, .Li 5 2 sub returns 3. .Sh COMMANDS .obc command_description_value_from_stack__: description .It Return current x and y Ta : Li currentpoint .It Exchange the top two values from the stack Ta : Li exch .It Return the top value from the stack Ta : Li pop .It Sum top two values Ta : Li add .It Sub top value from previous value Ta : Li sub .It Multiply top two values Ta : Li mul .It Divide the previous to last value by the top value Ta : div .El .Ss Usage Set new y position .obdl /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 .Ed .Bl -enum -compact .It Define margin_left as 10 .It Define line_height as 15 .It Get current x and y .It Exchange x and y to have x as the top value in the stack. .It Pop x out of the stack. .It Remove line_height from current y position to get the new y position. .It new_line: Move to x at margin_left and cur_y .El .Ss New text line .obdl /text_line { new_line /Helvetica sel_font show } def (line added with text_line) text_line .Ed .Sh TODO .obdi Add sample file. .El .Sh SEE ALSO .oxr dc oh .oxr latex oh .oxr pdf oh .Xr documentation oh .dm .Xr ps2pdf 1 .Ss links .obc2 .It - Lk https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf PLRM - PostScript Language Reference Manual .It - Lk https://archive.org/details/postscriptlangua00adobrich PostScript Language Tutorial and Cookbook .It - Lk https://hint.userweb.mwn.de/compiler/ThinkingInPostScript.pdf Thinking in PostScript .It - Lk http://www.tailrecursive.org/postscript/postscript.html A First Guide to PostScript .El .Sh AUTHORS .An -nosplit .Xr ohazot oh | .Xr about oh | .Lk https://ohazot.com ohazot.com .Aq Mt admin@ohazot.com