%!PS-Adobe-3.0 %%Title: EPSpre.ps - prepend to any EPS file to print it %%DocumentNeededResources: procset net.anastigmatix.StreamIO 0.1 8 %%+ net.anastigmatix.filter BinaryPreviewEPSDecode 0.1 3 %%+ procset net.anastigmatix.Import 0.1 13 %%Copyright: Chapman Flack - www.anastigmatix.net %%CreationDate: Sat Oct 28 00:30:23 EDT 2006 %%LanguageLevel: 2 %%EndComments % This file may be prepended to any EPS file and sent to a printer % to print the EPS figure. The figure is placed on the page in whichever % orientation allows it to be scaled to the largest size that will fit % without distorting its aspect ratio. The file may be a DOS EPS with % binary preview, as long as the communication channel to the printer % is transparent to binary data. % Caveat: a large EPS whose %%BoundingBox: comment says (atend) will consume % a large amount of memory. % This file is provided in the hope that it will be useful but AS-IS WITHOUT % ANY EXPRESS OR IMPLIED WARRANTY AND WITHOUT REPRESENTATION AS TO ITS % SUITABILITY FOR ANY PURPOSE. It may be freely distributed, hacked, used as an % example, extended, folded, spindled, or mutilated, as long as credit is given % and, if the net.anastigmatix resources it uses are distributed with it, THEY % are in their original form. One obvious extension would be to add some % options, so you could, for example, % echo '%!PS % /NoRotate true def' | cat - EPSpre.ps foo.eps | lpr % It is left as an exercise. :) %%BeginProlog %%IncludeResource: procset net.anastigmatix.StreamIO 0.1 8 %%IncludeResource: net.anastigmatix.filter BinaryPreviewEPSDecode 0.1 3 %%IncludeResource: procset net.anastigmatix.Import 0.1 13 %%EndProlog %%BeginSetup /net.anastigmatix.StreamIO /ProcSet findresource begin /net.anastigmatix.Import /ProcSet findresource begin 16 dict begin %%EndSetup %%Page: 1 1 { currentfile << >> /BinaryPreviewEPSDecode extfilter StatEPSF % stack: file llx lly urx ury { ury urx lly llx } { exch def } forall clippath pathbbox newpath % file llx lly urx ury { cuy cux cly clx } { exch def } forall /FigureWidth urx llx sub def /FigureHeight ury lly sub def /FigureOrientation FigureHeight FigureWidth ge { /Portrait } { /Landscape } ifelse def /MediumOrientation cuy cly sub cux clx sub ge { /Portrait } { /Landscape } ifelse def FigureOrientation MediumOrientation eq { /orx clx def /ory cly def /angle 0 def } { /orx cux def /ory cly def /angle 90 def /FigureHeight FigureWidth /FigureWidth FigureHeight def def } ifelse /scalefactor cux clx sub FigureWidth div cuy cly sub FigureHeight div 2 copy gt { exch } if pop def llx lly urx ury orx ory angle scalefactor scalefactor ReadyEPSF ExecEPSF showpage } bind exec