Coverage Report

Created: 2025-06-24 07:01

/src/ghostpdl/devices/gdevdjet.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2001-2023 Artifex Software, Inc.
2
   All Rights Reserved.
3
4
   This software is provided AS-IS with no warranty, either express or
5
   implied.
6
7
   This software is distributed under license and may not be copied,
8
   modified or distributed except as expressly authorized under the terms
9
   of the license contained in the file LICENSE in this distribution.
10
11
   Refer to licensing information at http://www.artifex.com or contact
12
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, for further information.
14
*/
15
16
/* HP LaserJet/DeskJet driver for Ghostscript */
17
#include "gdevprn.h"
18
#include "gdevdljm.h"
19
20
/*
21
 * Thanks for various improvements to:
22
 *      Jim Mayer (mayer@wrc.xerox.com)
23
 *      Jan-Mark Wams (jms@cs.vu.nl)
24
 *      Frans van Hoesel (hoesel@chem.rug.nl)
25
 *      George Cameron (g.cameron@biomed.abdn.ac.uk)
26
 *      Nick Duffek (nsd@bbc.com)
27
 * Thanks for the FS-600 driver to:
28
 *  Peter Schildmann (peter.schildmann@etechnik.uni-rostock.de)
29
 * Thanks for the LJIIID duplex capability to:
30
 *      PDP (Philip) Brown (phil@3soft-uk.com)
31
 * Thanks for the OCE 9050 driver to:
32
 *      William Bader (wbader@EECS.Lehigh.Edu)
33
 * Thanks for the LJ4D duplex capability to:
34
 *  Les Johnson <les@infolabs.com>
35
 */
36
37
/*
38
 * You may select a default resolution of 75, 100, 150, 300, or
39
 * (LJ4 only) 600 DPI in the makefile, or an actual resolution
40
 * on the gs command line.
41
 *
42
 * If the preprocessor symbol A4 is defined, the default paper size is
43
 * the European A4 size; otherwise it is the U.S. letter size (8.5"x11").
44
 *
45
 * To determine the proper "margin" settings for your printer, see the
46
 * file align.ps.
47
 */
48
49
/* Define the default, maximum resolutions. */
50
#ifdef X_DPI
51
#  define X_DPI2 X_DPI
52
#else
53
#  define X_DPI 300
54
#  define X_DPI2 600
55
#endif
56
#ifdef Y_DPI
57
#  define Y_DPI2 Y_DPI
58
#else
59
#  define Y_DPI 300
60
#  define Y_DPI2 600
61
#endif
62
63
/*
64
 * For all DeskJet Printers:
65
 *
66
 *  Maximum printing width               = 2400 dots = 8"
67
 *  Maximum recommended printing height  = 3100 dots = 10 1/3"
68
 *
69
 * All Deskjets have 1/2" unprintable bottom margin.
70
 * The recommendation comes from the HP Software Developer's Guide for
71
 * the DeskJet 500, DeskJet PLUS, and DeskJet printers, version C.01.00
72
 * of 12/1/90.
73
 *
74
 * Note that the margins defined just below here apply only to the DeskJet;
75
 * the paper size, width and height apply to the LaserJet as well.
76
 */
77
78
/* Margins are left, bottom, right, top. */
79
/* from Frans van Hoesel hoesel@rugr86.rug.nl. */
80
/* A4 has a left margin of 1/8 inch and at a printing width of
81
 * 8 inch this give a right margin of 0.143. The 0.09 top margin is
82
 * not the actual margin - which is 0.07 - but compensates for the
83
 * inexact paperlength which is set to 117 10ths.
84
 * Somebody should check for letter sized paper. I left it at 0.07".
85
 */
86
0
#define DESKJET_MARGINS_LETTER  (float)0.2, (float)0.45, (float)0.3, (float)0.05
87
0
#define DESKJET_MARGINS_A4  (float)0.125, (float)0.5, (float)0.143, (float)0.09
88
/* Similar margins for the LaserJet. */
89
/* These are defined in the PCL 5 Technical Reference Manual. */
90
/* Note that for PCL 5 printers, we get the printer to translate the */
91
/* coordinate system: the margins only define the unprintable area. */
92
0
#define LASERJET_MARGINS_A4 (float)0.167, (float)0.167, (float)0.167, (float)0.167
93
0
#define LASERJET_MARGINS_LETTER (float)0.167, (float)0.167, (float)0.167, (float)0.167
94
95
/* See gdevdljm.h for the definitions of the PCL_ features. */
96
97
/* The device descriptors */
98
static dev_proc_open_device(hpjet_open);
99
static dev_proc_close_device(hpjet_close);
100
static dev_proc_close_device(ljet4pjl_close);
101
static dev_proc_print_page_copies(djet_print_page_copies);
102
static dev_proc_print_page_copies(djet500_print_page_copies);
103
static dev_proc_print_page_copies(fs600_print_page_copies);
104
static dev_proc_print_page_copies(ljet_print_page_copies);
105
static dev_proc_print_page_copies(ljetplus_print_page_copies);
106
static dev_proc_print_page_copies(ljet2p_print_page_copies);
107
static dev_proc_print_page_copies(ljet3_print_page_copies);
108
static dev_proc_print_page_copies(ljet3d_print_page_copies);
109
static dev_proc_print_page_copies(ljet4_print_page_copies);
110
static dev_proc_print_page_copies(ljet4d_print_page_copies);
111
static dev_proc_print_page_copies(lp2563_print_page_copies);
112
static dev_proc_print_page_copies(oce9050_print_page_copies);
113
static dev_proc_print_page_copies(ljet4pjl_print_page_copies);
114
static dev_proc_get_params(hpjet_get_params);
115
static dev_proc_put_params(hpjet_put_params);
116
117
/* Since the print_page doesn't alter the device, this device can print in the background */
118
static void
119
hpjet_initialize_device_procs(gx_device *dev)
120
0
{
121
0
    gdev_prn_initialize_device_procs_mono_bg(dev);
122
123
0
    set_dev_proc(dev, open_device, hpjet_open);
124
0
    set_dev_proc(dev, close_device, hpjet_close);
125
0
    set_dev_proc(dev, get_params, hpjet_get_params);
126
0
    set_dev_proc(dev, put_params, hpjet_put_params);
127
0
}
128
129
/* Since the print_page doesn't alter the device, this device can print in the background */
130
static void
131
ljet4pjl_initialize_device_procs(gx_device *dev)
132
0
{
133
0
    gdev_prn_initialize_device_procs_mono_bg(dev);
134
135
0
    set_dev_proc(dev, open_device, hpjet_open);
136
0
    set_dev_proc(dev, close_device, ljet4pjl_close);
137
0
}
138
139
typedef struct gx_device_hpjet_s gx_device_hpjet;
140
141
struct gx_device_hpjet_s {
142
    gx_device_common;
143
    gx_prn_device_common;
144
    int MediaPosition;
145
    bool MediaPosition_set;
146
    bool ManualFeed;
147
    bool ManualFeed_set;
148
    bool Tumble;
149
};
150
151
#define HPJET_DEVICE(init, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, color_bits, print_page_copies)\
152
  { prn_device_std_margins_body_copies(gx_device_hpjet, init, dname, \
153
        w10, h10, xdpi, ydpi, lm, tm, lm, bm, rm, tm, color_bits, \
154
        print_page_copies), \
155
    0, false, false, false, false }
156
157
const gx_device_hpjet gs_deskjet_device =
158
HPJET_DEVICE(hpjet_initialize_device_procs, "deskjet",
159
             DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
160
             X_DPI, Y_DPI,
161
             0, 0, 0, 0,    /* margins filled in by hpjet_open */
162
             1, djet_print_page_copies);
163
164
const gx_device_hpjet gs_djet500_device =
165
HPJET_DEVICE(hpjet_initialize_device_procs, "djet500",
166
             DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
167
             X_DPI, Y_DPI,
168
             0, 0, 0, 0,    /* margins filled in by hpjet_open */
169
             1, djet500_print_page_copies);
170
171
const gx_device_hpjet gs_fs600_device =
172
HPJET_DEVICE(hpjet_initialize_device_procs, "fs600",
173
             DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
174
             X_DPI2, Y_DPI2,
175
             0.23, 0.0, 0.23, 0.04,      /* margins */
176
             1, fs600_print_page_copies);
177
178
const gx_device_hpjet gs_laserjet_device =
179
HPJET_DEVICE(hpjet_initialize_device_procs, "laserjet",
180
             DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
181
             X_DPI, Y_DPI,
182
             0.05, 0.25, 0.55, 0.25,  /* margins */
183
             1, ljet_print_page_copies);
184
185
const gx_device_hpjet gs_ljetplus_device =
186
HPJET_DEVICE(hpjet_initialize_device_procs, "ljetplus",
187
             DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
188
             X_DPI, Y_DPI,
189
             0.05, 0.25, 0.55, 0.25,  /* margins */
190
             1, ljetplus_print_page_copies);
191
192
const gx_device_hpjet gs_ljet2p_device =
193
HPJET_DEVICE(hpjet_initialize_device_procs, "ljet2p",
194
             DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
195
             X_DPI, Y_DPI,
196
             0.25, 0.25, 0.25, 0.0, /* margins */
197
             1, ljet2p_print_page_copies);
198
199
const gx_device_hpjet gs_ljet3_device =
200
HPJET_DEVICE(hpjet_initialize_device_procs, "ljet3",
201
             DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
202
             X_DPI, Y_DPI,
203
             0.20, 0.25, 0.25, 0.25,  /* margins */
204
             1, ljet3_print_page_copies);
205
206
const gx_device_hpjet gs_ljet3d_device =
207
HPJET_DEVICE(hpjet_initialize_device_procs, "ljet3d",
208
             DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
209
             X_DPI, Y_DPI,
210
             0.20, 0.25, 0.25, 0.25,  /* margins */
211
             1, ljet3d_print_page_copies);
212
213
const gx_device_hpjet gs_ljet4_device =
214
HPJET_DEVICE(hpjet_initialize_device_procs, "ljet4",
215
             DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
216
             X_DPI2, Y_DPI2,
217
             0, 0, 0, 0,    /* margins */
218
             1, ljet4_print_page_copies);
219
220
const gx_device_hpjet gs_ljet4d_device =
221
HPJET_DEVICE(hpjet_initialize_device_procs, "ljet4d",
222
             DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
223
             X_DPI2, Y_DPI2,
224
             0, 0, 0, 0,    /* margins */
225
             1, ljet4d_print_page_copies);
226
227
const gx_device_hpjet gs_lp2563_device =
228
HPJET_DEVICE(hpjet_initialize_device_procs, "lp2563",
229
             DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
230
             X_DPI, Y_DPI,
231
             0, 0, 0, 0,    /* margins */
232
             1, lp2563_print_page_copies);
233
234
const gx_device_hpjet gs_oce9050_device =
235
HPJET_DEVICE(hpjet_initialize_device_procs, "oce9050",
236
             24 * 10, 24 * 10,  /* 24 inch roll (can print 32" also) */
237
             400, 400,    /* 400 dpi */
238
             0, 0, 0, 0,    /* margins */
239
             1, oce9050_print_page_copies);
240
241
const gx_device_printer gs_ljet4pjl_device =
242
prn_device_copies(ljet4pjl_initialize_device_procs, "ljet4pjl",
243
           DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
244
           X_DPI2, Y_DPI2,
245
           0, 0, 0, 0,      /* margins */
246
           1, ljet4pjl_print_page_copies);
247
248
/* Open the printer, adjusting the margins if necessary. */
249
static int
250
hpjet_open(gx_device * pdev)
251
0
{       /* Change the margins if necessary. */
252
0
    gx_device_printer *const ppdev = (gx_device_printer *)pdev;
253
0
    const float *m = 0;
254
0
    bool move_origin = true;
255
256
0
    if (ppdev->printer_procs.print_page_copies == djet_print_page_copies ||
257
0
        ppdev->printer_procs.print_page_copies == djet500_print_page_copies
258
0
        ) {
259
0
        static const float m_a4[4] =
260
0
        {DESKJET_MARGINS_A4};
261
0
        static const float m_letter[4] =
262
0
        {DESKJET_MARGINS_LETTER};
263
264
0
        m = (gdev_pcl_paper_size(pdev) == PAPER_SIZE_A4 ? m_a4 :
265
0
             m_letter);
266
0
    } else if (ppdev->printer_procs.print_page_copies == oce9050_print_page_copies ||
267
0
               ppdev->printer_procs.print_page_copies == lp2563_print_page_copies
268
0
        );
269
0
    else {     /* LaserJet */
270
0
        static const float m_a4[4] =
271
0
        {LASERJET_MARGINS_A4};
272
0
        static const float m_letter[4] =
273
0
        {LASERJET_MARGINS_LETTER};
274
275
0
        m = (gdev_pcl_paper_size(pdev) == PAPER_SIZE_A4 ? m_a4 :
276
0
             m_letter);
277
0
        move_origin = false;
278
0
    }
279
0
    if (m != 0)
280
0
        gx_device_set_margins(pdev, m, move_origin);
281
    /* If this is a LJIIID, enable Duplex. */
282
0
    if (ppdev->printer_procs.print_page_copies == ljet3d_print_page_copies)
283
0
        ppdev->Duplex = true, ppdev->Duplex_set = 0;
284
0
    if (ppdev->printer_procs.print_page_copies == ljet4d_print_page_copies)
285
0
        ppdev->Duplex = true, ppdev->Duplex_set = 0;
286
0
    return gdev_prn_open(pdev);
287
0
}
288
289
/* hpjet_close is only here to eject odd numbered pages in duplex mode, */
290
/* and to reset the printer so the ink cartridge doesn't clog up. */
291
static int
292
hpjet_close(gx_device * pdev)
293
0
{
294
0
    gx_device_printer *const ppdev = (gx_device_printer *)pdev;
295
0
    int code = gdev_prn_open_printer(pdev, 1);
296
297
0
    if (code < 0)
298
0
        return code;
299
0
    if (ppdev->PageCount > 0) {
300
0
        if (ppdev->Duplex_set >= 0 && ppdev->Duplex)
301
0
            gp_fputs("\033&l0H", ppdev->file);
302
303
0
        gp_fputs("\033E", ppdev->file);
304
0
    }
305
306
0
    return gdev_prn_close(pdev);
307
0
}
308
309
static int
310
ljet4pjl_close(gx_device *pdev)
311
0
{
312
0
    gx_device_printer *const ppdev = (gx_device_printer *)pdev;
313
0
    int code = gdev_prn_open_printer(pdev, 1);
314
315
0
    if (code < 0)
316
0
        return code;
317
0
    if ( ppdev->Duplex_set >= 0 && ppdev->Duplex ) {
318
0
        code = gdev_prn_open_printer(pdev, 1);
319
0
        if (code < 0)
320
0
            return code;
321
0
        gp_fputs("\033&l0H", ppdev->file) ;
322
0
    }
323
0
    gp_fputs("\033%-12345X", ppdev->file);
324
0
    return gdev_prn_close(pdev);
325
0
}
326
327
/* ------ Internal routines ------ */
328
329
/* Make an init string that contains paper tray selection. The resulting
330
   init string is stored in buf, so make sure that buf is at least 5
331
   bytes larger than str. */
332
static void
333
hpjet_make_init(gx_device_printer *pdev, char buf[80], const char *str)
334
0
{
335
0
    gx_device_hpjet *dev = (gx_device_hpjet *)pdev;
336
0
    int paper_source = -1;
337
338
0
    if (dev->ManualFeed_set && dev->ManualFeed) paper_source = 2;
339
0
    else if (dev->MediaPosition_set && dev->MediaPosition >= 0)
340
0
        paper_source = dev->MediaPosition;
341
0
    if (paper_source >= 0)
342
0
        gs_snprintf(buf, 80, "%s\033&l%dH", str, paper_source);
343
0
    else
344
0
        gs_snprintf(buf, 80, "%s", str);
345
0
}
346
347
/* The DeskJet can compress (mode 2) */
348
static int
349
djet_print_page_copies(gx_device_printer * pdev, gp_file * prn_stream,
350
                       int num_copies)
351
0
{
352
0
    char init[80];
353
354
0
    hpjet_make_init(pdev, init, "\033&k1W\033*b2M");
355
0
    return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
356
0
                                        300, PCL_DJ_FEATURES, init, init, false);
357
0
}
358
/* The DeskJet500 can compress (modes 2&3) */
359
static int
360
djet500_print_page_copies(gx_device_printer * pdev, gp_file * prn_stream,
361
                          int num_copies)
362
0
{
363
0
    char init[80];
364
365
0
    hpjet_make_init(pdev, init, "\033&k1W");
366
0
    return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
367
0
                                        300, PCL_DJ500_FEATURES, init, init, false);
368
0
}
369
/* The Kyocera FS-600 laser printer (and perhaps other printers */
370
/* which use the PeerlessPrint5 firmware) doesn't handle        */
371
/* ESC&l#u and ESC&l#Z correctly.                               */
372
static int
373
fs600_print_page_copies(gx_device_printer * pdev, gp_file * prn_stream,
374
                        int num_copies)
375
0
{
376
0
    int dots_per_inch = (int)pdev->y_pixels_per_inch;
377
0
    char base_init[60];
378
0
    char init[80];
379
380
0
    gs_snprintf(base_init, sizeof(base_init), "\033*r0F\033&u%dD", dots_per_inch);
381
0
    hpjet_make_init(pdev, init, base_init);
382
0
    return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
383
0
                                        dots_per_inch, PCL_FS600_FEATURES,
384
0
                                        init, init, false);
385
0
}
386
/* The LaserJet series II can't compress */
387
static int
388
ljet_print_page_copies(gx_device_printer * pdev, gp_file * prn_stream,
389
                       int num_copies)
390
0
{
391
0
    char init[80];
392
393
0
    hpjet_make_init(pdev, init, "\033*b0M");
394
0
    return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
395
0
                                        300, PCL_LJ_FEATURES, init, init, false);
396
0
}
397
/* The LaserJet Plus can't compress */
398
static int
399
ljetplus_print_page_copies(gx_device_printer * pdev, gp_file * prn_stream,
400
                           int num_copies)
401
0
{
402
0
    char init[80];
403
404
0
    hpjet_make_init(pdev, init, "\033*b0M");
405
0
    return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
406
0
                                        300, PCL_LJplus_FEATURES, init, init, false);
407
0
}
408
/* LaserJet series IIp & IId compress (mode 2) */
409
/* but don't support *p+ or *b vertical spacing. */
410
static int
411
ljet2p_print_page_copies(gx_device_printer * pdev, gp_file * prn_stream,
412
                         int num_copies)
413
0
{
414
0
    char init[80];
415
416
0
    hpjet_make_init(pdev, init, "\033*r0F\033*b2M");
417
0
    return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
418
0
                                        300, PCL_LJ2p_FEATURES, init, init, false);
419
0
}
420
/* All LaserJet series IIIs (III,IIId,IIIp,IIIsi) compress (modes 2&3) */
421
/* They also need their coordinate system translated slightly. */
422
static int
423
ljet3_print_page_copies(gx_device_printer * pdev, gp_file * prn_stream,
424
                        int num_copies)
425
0
{
426
0
    char init[80];
427
428
0
    hpjet_make_init(pdev, init, "\033&l-180u36Z\033*r0F");
429
0
    return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
430
0
                                        300, PCL_LJ3_FEATURES, init, init, false);
431
0
}
432
/* LaserJet IIId is same as LaserJet III, except for duplex */
433
static int
434
ljet3d_print_page_copies(gx_device_printer * pdev, gp_file * prn_stream,
435
                         int num_copies)
436
0
{
437
0
    char init[80];
438
0
    char even_init[80];
439
440
0
    gx_device_hpjet *dev = (gx_device_hpjet *)pdev;
441
0
    bool tumble=dev->Tumble;
442
443
0
    hpjet_make_init(pdev, init, "\033&l-180u36Z\033*r0F");
444
0
    gs_snprintf(even_init, sizeof(even_init), "\033&l180u36Z\033*r0F");
445
0
    return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
446
0
                                        300, PCL_LJ3D_FEATURES, init, even_init, tumble);
447
0
}
448
/* LaserJet 4 series compresses, and it needs a special sequence to */
449
/* allow it to specify coordinates at 600 dpi. */
450
/* It too needs its coordinate system translated slightly. */
451
static int
452
ljet4_print_page_copies(gx_device_printer * pdev, gp_file * prn_stream,
453
                        int num_copies)
454
0
{
455
0
    int dots_per_inch = (int)pdev->y_pixels_per_inch;
456
0
    char base_init[60];
457
0
    char init[80];
458
459
0
    gs_snprintf(base_init, sizeof(base_init), "\033&l-180u36Z\033*r0F\033&u%dD", dots_per_inch);
460
0
    if (gdev_pcl_page_orientation((gx_device *) pdev) == PAGE_ORIENTATION_LANDSCAPE)
461
0
        gs_snprintf(base_init, sizeof(base_init), "\033&l0u140Z\033*r0F\033&u%dD", dots_per_inch);
462
0
    hpjet_make_init(pdev, init, base_init);
463
464
0
    return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
465
0
                                        dots_per_inch, PCL_LJ4_FEATURES,
466
0
                                        init, init, false);
467
0
}
468
static int
469
ljet4d_print_page_copies(gx_device_printer * pdev, gp_file * prn_stream,
470
                         int num_copies)
471
0
{
472
0
    int dots_per_inch = (int)pdev->y_pixels_per_inch;
473
0
    char base_init[60];
474
0
    char init[80];
475
0
    char even_init[80];
476
477
0
    gx_device_hpjet *dev = (gx_device_hpjet *)pdev;
478
0
    bool tumble=dev->Tumble;
479
480
    /* Put out per-page initialization. */
481
    /*
482
       Modified by karsten@sengebusch.de
483
       in duplex mode the sheet is alread in process, so there are some
484
       commands which must not be sent to the printer for the 2nd page,
485
       as this commands will cause the printer to eject the sheet with
486
       only the 1st page printed. This commands are:
487
       \033&l%dA (setting paper size)
488
       \033&l%dH (setting paper tray)
489
       in simplex mode we set this parameters for each page,
490
       in duplex mode we set this parameters for each odd page
491
       (paper tray is set by "hpjet_make_init")
492
    */
493
0
    gs_snprintf(base_init, sizeof(base_init), "\033&l-180u36Z\033*r0F\033&u%dD", dots_per_inch);
494
0
    hpjet_make_init(pdev, init, base_init);
495
0
    gs_snprintf(even_init, sizeof(even_init), "\033&l180u36Z\033*r0F\033&u%dD", dots_per_inch);
496
0
    return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
497
0
                                        dots_per_inch, PCL_LJ4D_FEATURES,
498
0
                                        init,even_init,tumble);
499
0
}
500
501
/* LaserJet 4 series compresses, and it needs a special sequence to */
502
/* allow it to specify coordinates at 600 dpi. */
503
/* It too needs its coordinate system translated slightly. */
504
static int
505
ljet4pjl_print_page_copies(gx_device_printer *pdev, gp_file *prn_stream,
506
                        int num_copies)
507
0
{ int dots_per_inch = (int)pdev->y_pixels_per_inch;
508
0
        char real_init[60];
509
510
0
        gs_snprintf(real_init, sizeof(real_init), "\033&l-180u36Z\033*r0F\033&u%dD", dots_per_inch);
511
0
        return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
512
0
                                        dots_per_inch, PCL_LJ4PJL_FEATURES,
513
0
                                        real_init, real_init, false);
514
0
}
515
516
/* The 2563B line printer can't compress */
517
/* and doesn't support *p+ or *b vertical spacing. */
518
static int
519
lp2563_print_page_copies(gx_device_printer * pdev, gp_file * prn_stream,
520
                         int num_copies)
521
0
{
522
0
    char init[80];
523
524
0
    hpjet_make_init(pdev, init, "\033*b0M");
525
0
    return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
526
0
                                        300, PCL_LP2563B_FEATURES, init, init, false);
527
0
}
528
/* The Oce line printer has TIFF compression */
529
/* and doesn't support *p+ or *b vertical spacing. */
530
static int
531
oce9050_print_page_copies(gx_device_printer * pdev, gp_file * prn_stream,
532
                          int num_copies)
533
0
{
534
0
    int code;
535
0
    char init[80];
536
537
    /* Switch to HP_RTL. */
538
0
    gp_fputs("\033%1B", prn_stream);  /* Enter HPGL/2 mode */
539
0
    gp_fputs("BP", prn_stream); /* Begin Plot */
540
0
    gp_fputs("IN;", prn_stream);  /* Initialize (start plot) */
541
0
    gp_fputs("\033%1A", prn_stream);  /* Enter PCL mode */
542
543
0
    hpjet_make_init(pdev, init, "\033*b0M");
544
545
0
    code = dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
546
0
                                        400, PCL_OCE9050_FEATURES, init, init, false);
547
548
    /* Return to HPGL/2 mode. */
549
0
    gp_fputs("\033%1B", prn_stream);  /* Enter HPGL/2 mode */
550
0
    if (code == 0) {
551
0
        gp_fputs("PU", prn_stream); /* Pen Up */
552
0
        gp_fputs("SP0", prn_stream);  /* Pen Select */
553
0
        gp_fputs("PG;", prn_stream);  /* Advance Full Page */
554
0
        gp_fputs("\033E", prn_stream);  /* Reset */
555
0
    }
556
0
    return code;
557
0
}
558
559
static int
560
hpjet_get_params(gx_device *pdev, gs_param_list *plist)
561
0
{
562
0
    gx_device_hpjet *dev = (gx_device_hpjet *)pdev;
563
0
    int code = gdev_prn_get_params(pdev, plist);
564
565
0
    if (code >= 0)
566
0
    {
567
0
        code = param_write_bool(plist, "ManualFeed", &dev->ManualFeed);
568
0
    }
569
0
    if (code >= 0)
570
0
    {
571
0
        code = param_write_int(plist, "MediaPosition", &dev->MediaPosition);
572
0
    }
573
0
    if (code >=0)
574
0
        code = param_write_bool(plist, "Tumble", &dev->Tumble);
575
0
    return code;
576
0
}
577
578
static int
579
hpjet_put_params(gx_device *pdev, gs_param_list *plist)
580
0
{
581
0
    gx_device_hpjet *dev = (gx_device_hpjet *)pdev;
582
0
    int code;
583
0
    bool ManualFeed;
584
0
    bool ManualFeed_set = false;
585
0
    int MediaPosition;
586
0
    bool MediaPosition_set = false;
587
0
    bool Tumble;
588
589
0
    code = param_read_bool(plist, "ManualFeed", &ManualFeed);
590
0
    if (code == 0) ManualFeed_set = true;
591
0
    if (code >= 0) {
592
0
        code = param_read_int(plist, "MediaPosition", &MediaPosition);
593
0
        if (code == 0) MediaPosition_set = true;
594
0
        else if (code < 0) {
595
0
            if (param_read_null(plist, "MediaPosition") == 0) {
596
0
                code = 0;
597
0
            }
598
0
        }
599
0
    }
600
0
    if (code>=0)
601
0
    {
602
0
       code=param_read_bool(plist,"Tumble",&Tumble);
603
0
       if (code != 0) Tumble = false; /* default: no tumble */
604
0
    }
605
606
0
    if (code >= 0)
607
0
        code = gdev_prn_put_params(pdev, plist);
608
609
0
    if (code >= 0) {
610
0
    dev->Tumble=Tumble;
611
0
        if (ManualFeed_set) {
612
0
            dev->ManualFeed = ManualFeed;
613
0
            dev->ManualFeed_set = true;
614
0
        }
615
0
        if (MediaPosition_set) {
616
0
            dev->MediaPosition = MediaPosition;
617
0
            dev->MediaPosition_set = true;
618
0
        }
619
0
    }
620
621
0
    return code;
622
0
}