------------------------------------------------------------------------------- Minimal Encapulated PS 1/ %!PS-Adobe-3.0 EPSF-3.0 header comment 2/ %%BoundingBox: llx lly urx ury ------------------------------------------------------------------------------- Create a A5 booklet Using psutils convert a sequence of A4 pages into a A5 booklet for binding (presumably with duplix printing) psbook | psnup -2 | pstops '2:0U@1(21cm,29.9cm),1' UNTESTED ------------------------------------------------------------------------------- Convert letter to A4 papaer psresize -Pa4 UNTESTED ------------------------------------------------------------------------------- Postscript to Images (anti-aliasing fonts) If you just convert a postscript file to an image directly (using ghostscript), you will get it at 72dpi resolution (yuck). A better idea is to do this at a larger resolution and then shrink it so that the edges are properly anti-aliased... Example: convert -density 288 -geometry 25% foo.ps foo.jpg Convert is a ImageMagick command. It calls ghostscript to convert postscript to pbmplus format before converting (and shinking) to the final jpeg image. NOTE: Density 288 is 4 times the normal 72 dpi screen (and image) resolution. Also the bigger you render the images the more memory and CPU power you need ... 2x2 or 3x3 is probably good enough for web pages. ASIDE: If you need more antialiasing, you can blur the image a little bit before you reduce its size. WARNING: ImageMagcik version 6 is using up far too much memory for this. Raw conversion First what devices are available in ghostscipt gs -h Direct covert (on to a trasnparent background gs -q -dBATCH -dNOPAUSE -sDEVICE=pngalpha \ -sOutputFile=image.png postscript.ps White background (greyscale) use "-sDEVICE=pngmono" instead If the image did not draw on the A4 page correctly use -g595x842 You increase the resolution with -r288x288 Final example... gs -q -dBATCH -dNOPAUSE -sDEVICE=pnggray -r216 -g1785x2526 \ -sOutputFile=- input.ps | convert - -resize 33% image.png ------------------------------------------------------------------------------- Postscript to Text Document... Generally this is NOT posiable... Postscript is a computer language (not a true data file format) for printers and as such can have an infinate number of formats and layouts. However Ghostscript (a postscript interpeter and displayer for unix) can be used to extract the TEXT from a postscript file! The script ps2ascii provided with ghostscript (see it library area) will do this. Note this is VERY simple minded, but should get you the text of the file. the spacing however is likely to be all over the place. The only other way is to convert it to a image then use a character recognition scanner (like OCR) to convert the image text back into plain text or wordprocessor document file. ------------------------------------------------------------------------------- Postscript to PDF Notes (incomplete) Generally I wanted to generate small PDF files from postscript pages containing very large high quality images... Tested methods and results.. Original file 05_editorial.ps --> 1 Mbyte Convert to anti-aliased image convert -colorspace gray -density 288 -geometry 25% \ 05_editorial.ps 05_editorial.png --> 144 Kb Image converted to PDF convert 05_editorial.png 05_editorial_img.pdf --> 188 Kb Ghostscript converted (gs provided script) ps2pdf 05_editorial.ps mv 05_editorial.png 05_editorial_gs2pdf.pdf --> 467 Kb Very Bad Result "Distiller" Commercial Filter (test verion contributed) --> 05_editorial_distilled.pdf --> 34 Kb VERY GOOD RESULT The main problem is that Distiller is a licenced comercial program. ------------------------------------------------------------------------------- To add a Encapulated PS preview bitmap - take the normal bitmap of the program and reverse the colors (0=white 1=black) and prefix `% ' to each line sizes are in pixels ....header.... %%EndComment %%BeginPreview: Xsize Ysize bitplanes lines % fffffffffffffffc % fffffffffffffffc % c00000000000000c % c00000000000000c % c00000000000000c % c00000000000000c ... etc .... % fffffffffffffffc %%EndPreview %%Pages: 1 %%EndProlog %%Page: 1 1 ....normal postscript.... showpage %%Trailer ------------------------------------------------------------------------------- Bitmapped graphics is slow! Summery: convert images to grey scale first! PS has always been terribly slow & clumsy at bitmap graphics. The language was designed for vector stuff. In short: printing bitmap graphics is very CPU bound and postscript printers generally don't require a fast CPU for printing. There is a real cure, but only if you are printing gray scale. With convert (ImageMagick), use the option "-colorspace gray", and the colour-to-grayscale conversion is done by convert instead of by the printer. I had an image filling an A4 page once, with colours in teh postscript it took 30min or so to print on an HP LJ4mv, already converted to grayscale it took a mere 20 seconds. This seems to be typical. Of course, when you want to print colour you just have to wait. :-( Volker Kuhlmann Thanks to all who replied to my question, especially Volker Kuhlmann convert -label "%f" -colorspace gray -rotate "-90>" -adjoin \ *.gif PS:printfile.ps This prints at 20sec/page instead of 2.5min/page !! even though the printfile is no smaller. Losing color is OK for me. --Doug Eardley (doug@itp.ucsb.edu) ------------------------------------------------------------------------------- Fancy Page output %!PS /showpage { % print some additional borders or texts here systemdict begin showpage end } bind def % ...add normal postscript page here... showpage Fails with a multipage printing program unless the old showpage is saved and used. For example see postscript filters Nup, multips, multicopy, etc. ------------------------------------------------------------------------------- Size of drawing area "clippath pathbbox" will return the size of the area available to draw in. "gsave initclip clippath pathbbox grestore" will give the full imaging area, but at the expense of any enveloping program. Like multipage PS wrapper program (See Fancy Page output above). ------------------------------------------------------------------------------- Reset the Printer Completely %!PS serverdict begin 0 exitserver systemdict /quit get exec ------------------------------------------------------------------------------- Make a font persistant %!PS-Adobe-2.0 ExitServer %%BeginExitServer: 0 serverdict begin 0 exitserver %%EndExitServer % Test for existence of font, abort if present. % This won't work on a printer with a hard disk! /str 32 string def /Eurostile dup FontDirectory exch known { str cvs print ( is already loaded!\n) print flush quit } { (loading font ) print str cvs print (\n) print flush } ifelse %% Font follows... Just do not download persistent fonts unless you really want them to persist indefinitely. If you want them only for one job, download them as part of the job. Level 2 printers can remove fonts with "undefinefont" Level 1 only by power cycling or the above reset command to remove ALL persistant fonts. ------------------------------------------------------------------------------- Text to PS Try any of the following programs: asciiprint.ps i2ps nenscript a2ps swtext ato2pps lpp printer asc2ps text2ps cz lwf psf ps2txt ascii2ps ETSR POSTPRN psfx80 pstext paps TranScript enscript PSR I also wrote a lp_filter which is a PS program you prepend to the front of your text file and it will output the following text as if it is to a old dot-matrix or tele-type line printer, including overstriking and bold! A simple solution for situations with limited access to text-to-postscript converters. Examples 2-up printing (solaris) /usr/lib/lp/postscript/postprint -n2 ------------------------------------------------------------------------------- Getting Postscript Printer Page Count Send the following to the printer %! (%%[ pagecount: )print statusdict/pagecount get exec( )cvs print ( ]%%)= flush and read the return output from the printer. WARNING: some printers 'background' print jobs, so they can start reading the next job BEFORE the last one is fully printed. Such printers do NOT return correct page counts of print jobs. ------------------------------------------------------------------------------- Double sided printing For postscript printers which support this you can.... For latex files, add the following line after the \documentstyle line: \special{!statusdict begin statusdict/setduplexmode known {true setduplexmode} if end} which is from the file /usr/local/lib/tex/ps/duplex For direct postscript (near the start) statusdict begin statusdict/setduplexmode known {true setduplexmode} if end -------------------------------------------------------------------------------