%!PS-Adobe-3.0This indicates DSC version 3 - it should not be confused with PostScript Level 3. Other DSC comments all start with %%. Some example DSC comments are:
%%Pages: 20 %%Orientation: Landscape %%LanguageLevel: 2A big problem with using DSC comments is that many programs and printer drivers produce incorrect DSC comments.
%%DocumentMedia: a4 595 842 80 () ()The parameters are name, width (in PostScript pts = 1/72"), height, weight (gsm), colour, and pre-printed form. The orientation should be given by the line
%%Orientation: PortraitIf orientation is Landscape, the image is rotated 90 degrees clockwise. The image width is thus the page height. If Portrait, the image is unchanged.
<< /PageSize [595 842] >> setpagedeviceAt the same time as setting the page size, you can also set the orientation. This doesn't make much sense for printers which have only one paper orientation. For printers which write to roll film, the orientation can determine whether the image is across the film, or lengthwise down the film. To request a 90 degree rotation:
<< /PageSize [595 842] /Orientation 3 >> setpagedevice
Most pages are printed in Portrait. An example portrait PostScript file is:
%!PS-Adobe-3.0 %%Orientation: Portrait %%DocumentMedia: a4 595 842 80 () () %%Pages: 1 %%EndComments %%EndProlog %%BeginSetup % A4, unrotated << /PageSize [595 842] /Orientation 0 >> setpagedevice %%EndSetup %%Page: 1 1 %%BeginPageSetup %%EndPageSetup % This is standard portrait orientation on A4 paper. /Helvetica findfont 220 scalefont setfont 72 600 moveto (ABC) show showpage %%Trailer %%EOF
This is the most common method for "landscape". GSview will display it correctly, provided that it includes %%Orientation: Landscape. This method will print correctly. When converted to PDF, you will need to turn your monitor on its side. A later section shows how to do landscape on portrait paper such that PDF is displayed correctly. An example PostScript file is:
%!PS-Adobe-3.0 %%Orientation: Landscape %%DocumentMedia: a4 595 842 80 () () %%Pages: 1 %%EndComments %%EndProlog %%BeginSetup << /PageSize [595 842] /Orientation 0 >> setpagedevice %%EndSetup %%Page: 1 1 %%BeginPageSetup 90 rotate 0 -595 translate %%EndPageSetup % This page prints on standard A4 portrait paper. % You need to turn your head 90 degrees to view this page % in GSview, or after converting to PDF. /Helvetica findfont 220 scalefont setfont 72 72 moveto (ABCD) show showpage %%Trailer %%EOF
This will view correctly in GSview, and convert correctly
to PDF and bitmaps using Ghostscript. When you try to print
it you may end up with:
This is undesirable. For this reason, I recommend against
using this method for producing landscape orientation.
An example PostScript file is:
%!PS-Adobe-3.0 %%Orientation: Portrait %%DocumentMedia: a4land 842 595 80 () () %%Pages: 1 %%EndComments %%EndProlog %%BeginSetup % A4 landscape orientation << /PageSize [842 595] /Orientation 0 >> setpagedevice %%EndSetup %%Page: 1 1 %%BeginPageSetup %%EndPageSetup % This page prints on landscape A4 portrait paper. % Some printers will print this page unrotated with right % part of the image truncated where it falls off the page. % "%%DocumentMedia: (XXX) 842 595" and "%%Orientation: Portrait" % allows normal viewing in GSview. % "/PageSize [842 595] /Orientation 0" allows normal viewing % after converting to PDF. % This is NOT the preferred way to do landscape documents in % PostScript and PDF, although it is valid. /Helvetica findfont 220 scalefont setfont 72 72 moveto (ABCD) show showpage %%Trailer %%EOF
In GSview and when converted to PDF it will view as:
Depending on the output device, this may print correctly, or it may print with the right part of the image truncated. PDF and bitmap output from Ghostscript will be the same as viewed. An example PostScript file is:
%!PS-Adobe-3.0 %%Orientation: Landscape %%DocumentMedia: a4 595 842 80 () () %%Pages: 1 %%EndComments %%EndProlog %%BeginSetup % A4, rotated 90 degrees ACW << /PageSize [595 842] /Orientation 3 >> setpagedevice %%EndSetup %%Page: 1 1 %%BeginPageSetup 90 rotate 0 -595 translate %%EndPageSetup % This page prints on standard A4 portrait paper. % "%%Orientation: Landscape" allows normal viewing in GSview. % "/Orientation 3" allows normal viewing after converting to PDF. % This is the preferred way to do landscape documents in % PostScript, especially when converting to PDF. /Helvetica findfont 220 scalefont setfont 72 72 moveto (ABCD) show showpage %%Trailer %%EOFNote that the only difference between this method and the earlier "Rotated image on Portait paper" is that the setpagedevice /Orientation is 3, not 0. Hand editing the PostScript file can fix that!