Patch-ID# 100135-05
Keywords: SunOS 4.0.3 GKS 3.0 
Synopsis: SunGKS 3.0:Postscript driver limits output to 8.5 x 11" paper size 
Date: 10-Jan-91 

SunOS release: 4.0.3 

Unbundled Product: SunGKS

Unbundled Release: 3.0

Topic: 

BugID's fixed with this patch: 1043100

Architectures for which this patch is available: Sun4

Obsoleted by: 3.0.1, 4.0

Problem Description:
	When filling the page in the width direction the printer cuts off
        the right edge because gks specified a maximum width outside the
        imageable region or surface on a laser printer. 

	Build your application as follows:
	Copy gkswsconfig.h into /usr/include/gks as root user

	For C bindings: 
	cc myfile.c gcf.o pscript.o -I$GKSDIR/../../include -L$GKSDIR/../../lib -lgks -lsuntool -lsunwindow -lpixrect -lm

	For FORTRAN bindings:
	f77 myfile.f fgcf.o gcf.o pscript.o -I$GKSDIR/../../include -L$GKSDIR/../../lib -lgks77 -lgks -lsuntool -lsunwindow -lpixrect -lm


New Config attributes for the postscript workstation type

In order to set the paper width and height on a laser printer to
accommodate various world standards, use the following attributes::

GKS_PSTSCRIPT_PAPER_WIDTH
GKS_PSTSCRIPT_PAPER_HEIGHT

They are used as attribute - value pairs(the value of type int)

There are also predefined paper sizes which can be used as values:

USLETTER_WIDTH
USLETTER_HEIGHT
USLEGAL_WIDTH
USLEGAL_HEIGHT
ISOA4_WIDTH
ISOA4_HEIGHT

Also the gkswsconfig.h can be edited in order to change the default paper
size(US Letter). Edit attributes:

#define GKS_DEFAULT_PSTSCRIPT_PAPER_WIDTH
#define GKS_DEFAULT_PSTSCRIPT_PAPER_HEIGHT


For example:

#ifndef lint
static  char sccsid[] = "@(#)hcopy.c 12.1 90/10/5";
#endif

/*
 * Copyright (c) 1989 by Sun Microsystems, Inc.
 */


/*
 *      Draws different output primitives on a sun_tool workstation.
 *      and a choice item for which hardcopy output.  The choices
 *      are Postscript, HP 7475 A size, 7550 B size, and 7586 E size,
 *      or Quit to quit the application.
 */

#include <gks/ansicgks.h>

Gcolour object[8 * 9] = { 2, 0, 0, 0, 0, 0, 0, 0, 2,
                          2, 8, 0, 1, 0, 1, 0, 4, 2,
                          2, 8, 1, 0, 1, 0, 1, 4, 2,
                          2, 8, 0, 1, 0, 1, 0, 4, 2,
                          2, 8, 1, 0, 1, 0, 1, 4, 2,
                          2, 8, 0, 1, 0, 1, 0, 4, 2,
                          2, 8, 4, 4, 4, 4, 4, 4, 2,
                          2, 3, 3, 3, 3, 3, 3, 3, 2 };
Gipoint dim = { 8, 9 };
Gwpoint place1 = { 0.1,0.7 };
Gwpoint place2 = { 0.3,0.0 };
Gwpoint place3 = { 0.3,0.1 };
Gwrect rect = { {0.6,0.6} , {0.7,0.7} };
Gwpoint square_fill[5] = { 0.2,0.2 ,
                            0.2,0.3 ,
                            0.3,0.3 ,
                            0.3,0.2 ,
                            0.2,0.2 };
Gwpoint square_empty[5] =  { 0.0,0.0 ,
                            0.0,1.0 ,
                            1.0,1.0 ,
                            1.0,0.0 ,
                            0.0,0.0 };
Gwpoint square_mark[4] =  { 0.8,0.8 ,
                            0.8,0.9 ,
                            0.9,0.9 ,
                            0.9,0.8 };

main()
{
    Gescin escin;
    char *strarray[1];
    Gchar *conn = NULL;
    Gchar *text = "This is a string.";
    Gchar *wstype = "sun_tool";
    Gchar *wisstype = "wiss";
    Gflinter intstyle = SOLID;
    Gmktype marker = 2; /* PLUS sign */
    Gws ws = 1;
    Gws wiss = 2;
    int n = 5;
    int quit,hc_type,hpgl_type,ps_type;
    Gseg segment = 1;
    Gqchoice rqch;
    Gchoicerec rec;
    Gchoicest chst;
    Gpet pet;
    Guchpet1 pet1;
    int perrind;
    char *hc_choices[7];

    /*
     * Open GKS.  Open and activate a sun_tool workstation.
     * Open and activate workstation independent segment storage
     * device.
     */
    if (gopengks(stdout, GMEMORY))
        exit(2);
    gopenws(ws, conn, wstype);
    gopenws(wiss, conn, wisstype);
    gactivatews(ws);
    gactivatews(wiss);

    /*
     * Create a segment containing an empty square polyline,
     * a polygon, a cell array, and a marker.  Close the segment.
     * The segment is displayed on the sun_tool workstation and
     * stored into WISS (workstation independent segment storage).
     */
    gcreateseg(segment);
    gpolyline(5, square_fill);  
    gpolyline(5, square_empty);
    gsetfillintstyle(intstyle);  
    gfillarea(5, square_fill);   
    gcellarray(&rect, &dim, 8, object); 
    gsetmarkertype(marker);    
    gpolymarker(4, square_mark);  
    gtext(&place1, text);    
    gcloseseg();

    /*
     * Set up choice item with choices:  Postscript,
     * HP7475 A Size, HP7550 B Size, HP7586 E Size and
     * quit item.
     */
    quit = 0;
        hc_choices[0] = "Postscript Letter Size";
        hc_choices[1] = "Postscript Legal Size";
        hc_choices[2] = "Postscript ISO A4 Size";
        hc_choices[3] = "HP7475 A Size";
        hc_choices[4] = "HP7550 B Size";
        hc_choices[5] = "HP7586 E Size";
        hc_choices[6] = "Quit";


        /*
         * Inquire the state of the choice device.
         * Then set up other choice device structures.
         */
        chst = ginqchoicestate(ws, 1, &perrind);
        pet1.number = n;
        pet1.strings = hc_choices;
        pet1.alt = &n;
        pet1.colour = 15;
        rec.pet1.data = (Gchar*)&pet1;
        ginitchoice(ws, 1, 1, 1, &chst.e_area, &rec);

        hc_type = 0; /* 1 = postscript, 2 = HPGL */
        hpgl_type = 0; /* 0 = HP7475, 1 = HP7550, 2 = HP7586 */

        /*
         * Until the user selects quit, request the user's choice
         * of printer: 1 = HP7550, 2 = HP7586 = HP7475, and then
         * output the rendered image out to the printer.
         */
        while (!quit && (hc_type == 0)) {
            gmessage(ws, "Please select hardcopy output type.\n");
            rqch = greqchoice(ws, 1);
            gmessage(ws, "\n");
            if (rqch.status == C_OK) {
                switch (rqch.choice) {
                    case 1:
                        hc_type = 1;   /* Postscript */
                        ps_type = 0;   /* Postscript 8.5 x 11 */
                        gmessage(ws, "Postscript 8.5 x 11 selected.\n");
                        break;
                    case 2:
                        hc_type = 1;   /* Postscript */
                        ps_type = 1;   /* Postscript 8.5 x 14 */
                        gmessage(ws, "Postscript 8.5 x 14 selected.\n");
                        break;
                    case 3:
                        hc_type = 1;   /* Postscript */
                        ps_type = 2;   /* Postscript ISO A4 */
                        gmessage(ws, "Postscript ISO A4 selected.\n");
                        break;
                    case 4:
                        hc_type = 2;   /* HPGL */
                        hpgl_type = 0; /* HP7475 */
                        gmessage(ws, "HP7475 selected.\n");
                        break;
                    case 5:
                        hc_type = 2;   /* HPGL */
                        hpgl_type = 1; /* HP7550 */
                        gmessage(ws, "HP7550 selected.\n");
                        break;
                    case 6:
                        hc_type = 2;   /* HPGL */
                        hpgl_type = 2; /* HP7586 */
                        gmessage(ws, "HP7586 selected.\n");
                        break;
                    case 7:
                        quit = 1;
                        gmessage(ws, "quitting now ...\n");
                        break;
                    default:
                        gmessage(ws,"Invalid choice.\n");
                        break;
                 }
             }    

        }

        /*
         * If the user didn't select quit, then open and
         * activate the user's chosen output device.  Copy
         * the segment to the output device.
         */
        if (!quit) {
            if (hc_type == 1) { /* Postscript */
                Gchar *psconn = "postscript.ps";
                Gchar *pswstype = "postscript";
                Gws   psws = 3;
                Gks_ws_config  config;
                int  minx,miny,maxx,maxy;

                switch(ps_type) {
                   case 0: /* Postscript 8.5 x 11 inches */
                        psconn = "postscript-letter.ps";
                        printf("letter type.\n");
                        config = gks_ws_config_get_installed(pswstype);
                        gks_ws_config_set(config,
                                GKS_PSTSCRIPT_PAPER_WIDTH, USLETTER_WIDTH,
                                GKS_PSTSCRIPT_PAPER_HEIGHT, USLETTER_HEIGHT,
                                0);
                        break;
                   case 1: /* Postscript A size paper - "legal" */
                        psconn = "postscript-legal.ps";
                        printf("Legal type.\n");
                        config = gks_ws_config_get_installed(pswstype);
                        gks_ws_config_set(config,
                                GKS_PSTSCRIPT_PAPER_WIDTH, USLEGAL_WIDTH,
                                GKS_PSTSCRIPT_PAPER_HEIGHT, USLEGAL_HEIGHT,
                                0);
                        break;
                    case 2: /* Postscript ISO A4 size paper */
                        psconn = "postscript-isoA4.ps";
                        printf("ISO A4 type.\n");
                        config = gks_ws_config_get_installed(pswstype);
                        gks_ws_config_set(config,
                                GKS_PSTSCRIPT_PAPER_WIDTH, ISOA4_WIDTH,
                                GKS_PSTSCRIPT_PAPER_HEIGHT, ISOA4_HEIGHT,
                                0);
                   default:
                        break;
                } /* end switch(ps_type) */

                gks_ws_config_install(config);

                gopenws(psws, psconn, pswstype);
                gactivatews(psws);
                gcopysegws(psws,segment);
                gdeactivatews(psws);
                gclosews(psws);
            }
            else { /* HPGL */
                Gchar *hpconn;
                Gchar *hpwstype = "hpgl";
                Gws   hpws = 4;
                int   hp_num_colours,hp_solid_fill,minx,miny,maxx,maxy;
                char  *hp_title;
                Gks_ws_config config;

                switch(hpgl_type) {
                    case 0:  /* HP7475 A size paper */
                        hp_num_colours = 6; /* 6 Pens */
                        hp_solid_fill = 0;  /* Solid fill not supported */
                        hp_title = "HP7475 output from SunGKS 2.1";
                        minx = 250;  /* from the table: Default Scaling Points*/                        miny = 596;  /* Chapter 2, Interfacing and Programming*/                        maxx = 10250;/* Manual HP7475A Graphics Plotter       */                        maxy = 7796;
                        hpconn = "HP7475.plot";
                        break;
                    case 1: /* HP7550 B size paper */
                        hp_num_colours = 8; /* 8 Pens */
                        hp_solid_fill = 1;  /* Solid fill is supported */
                        hp_title = "HP7550 output from SunGKS 2.1";
                        minx = 620;  /* from the table: Default Scaling Points*/                        miny = 80;   /* Chapter 2, Interfacing and Programming*/                        maxx = 15820;/* Manual HP7550A Graphics Plotter       */                        maxy = 10080;
                        hpconn = "HP7550.plot";
                        break;
                    case 2: /* HP7586 E size paper */
                    default:
                        hp_num_colours = 8; /* 8 Pens */
                        hp_solid_fill = 1;  /* Solid fill is supported */
                        hp_title = "HP7586 output from SunGKS 2.1";
                        minx = -20840;/* from the table: Typical HP 7585/7586 */                        miny = -16180;/* Default Coordinate Values, Chapter 2,*/                        maxx = 20840; /* 7580B, 7585B,7586B Drafting Plotters */                        maxy = 16180; /* Interfacing and Programming Guide    */                        hpconn = "HP7586.plot";
                        break;
                } /* end switch(hpgl_type) */

                config = gks_ws_config_get_installed(hpwstype);
                gks_ws_config_set(config,
                    GKS_NUM_COLOR, hp_num_colours,
                    GKS_HP_SOLID_FILL, hp_solid_fill,
                    GKS_HP_TITLE, hp_title,
                    GKS_HP_MINX, minx,
                    GKS_HP_MINY, miny,
                    GKS_HP_MAXX, maxx,
                    GKS_HP_MAXY, maxy,
                    0);
                gks_ws_config_install(config);

                gopenws(hpws, hpconn, hpwstype);
                gactivatews(hpws);
                gcopysegws(hpws,segment);
                gdeactivatews(hpws);
                gclosews(hpws);
            }
        }    

    /*
     * Deactivate and close the GKS and WISS workstations.
     * Close GKS.
     */
    gdeactivatews(ws);
    gdeactivatews(wiss);
    gclosews(ws);
    gclosews(wiss);
    gclosegks();
}


