summaryrefslogtreecommitdiffstats
path: root/docs/textdocs/CUPS-PrintingInfo.txt
blob: bbe14f33e8f84acbe7dfdd864d6568f44145392a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
Date: Sun, 22 Sep 2002 15:38:02 +0200
From: "Kurt Pfeifle" <kpfeifle@danka.de>
Reply-To: kpfeifle@danka.de
Organization: Danka Deutschland GmbH
To: samba@lists.samba.org
Subject: CUPS filtering mechanism explained, was: [cups raw mode, was Re: [Samba] unlink data file in cups_job_submit]

Paul Janzen wrote on Samba digest:

 > Message: 7
 > To: Gerald Carter <jerry@samba.org>
 > Cc: samba@lists.samba.org
 > From: Paul Janzen <pcj@samba.sez.to>
 > Subject: cups raw mode, was Re: [Samba] unlink data file in cups_job_submit
 > Date: 21 Sep 2002 12:09:23 -0700
 >
 >
 > Gerald Carter <jerry@samba.org> writes:
 >
 >  > Looks right to me  [:-)] Applying it now.  Thanks.  I've been meaning to
 >  > track this one down.
 >
 >
 > Thanks!
 >
 > While we are on the subject...  [:-)]
 >
 > If I am using native printer drivers on Windows clients, I would like
 > the "raw" option to get propagated to CUPS.  Otherwise cups does not
 > pass the data on to the printer.

Paul,

I see you know about what you call the "raw data passthrough feature".
I guess you mean the lines in "/etc/cups/mime.types" and
"/etc/cups/mime.convs" which need to be uncommented to allow "raw"
printing ?

Here is some clarification (likely not very useful for you, but
possibly for some other readers of the Samba list):

###  If you have "printing = cups" and "printcap = cups" enabled,
---  everything is handled by Samba accessing the CUPS API. (And any
      "print command" directive in Samba will be ignored.) If the CUPS
      API is not available (because Samba might not be compiled against
libcups), it automatically maps to the "System V" command set, with
"-oraw" enabled automatically.

 > (If I enable cups's application/
 > octet-stream raw-data passthrough feature, both cupsomatic and the
 > Windows driver add PJL headers and footers, which is not what I want
 > either.)

###  According to my experience, cupsomatic on the Samba/CUPS server
---  does *not* add any features if a file is really printed "raw".
      However, if you have loaded the driver for the Windows client
from the CUPS server, using the "cupsaddsmb" utility, and if this
driver is one using a "Foomatic" PPD, the PJL header in question is
already added on the Windows client, at the time when the driver
initially generated the PostScript data -- and CUPS in true "-oraw"
manner doesn't remove this PJL header and passes the file "as is"
to its printer communication backend.

NOTE,  please, that the editing in the "mime.convs" and the
-----  "mime.types" file does not *enforce* "raw" printing, it
        only *allows* it. Any file arriving from Windows is
"auto-typed" by CUPS, which might consecutively lead to its
treatment by various filters automatically (depending on the
actual outcome of the auto-typing and the configuration of the
printqueue in question):

     --> Files generated by PCL drivers and destined to PCL
         printers get auto-typed "application/octet-stream"
         and are indeed printed "raw". Also, unknown file
         types are getting tagged as "application/octet-stream".

     --> Files generated by a PostScript driver (and destined
         for any target printer type) are auto-typed. Depending
         on the driver, the discovered MIME type may be

           * application/postscript or
           * application/vnd.cups-postscript

"application/postscript" goes first thru the "pstops" filter
    (where also the page counting and accounting takes place
    currently), and the outcome will be of MIME type
    "application/vnd.cups-postscript". The pstopsfilter reads and
    uses information from the PPD and inserts user-provided options
    into the PostScript file. As a consequence, the filtered file
    will possibly have the PJL header you don't want.

"application/postscript" will be all files with a ".ps", ".ai",
    ".eps" suffix or which have as their first character string one
    of "%!" or "<04>%".

"application/vnd.cups-postscript" will be those files which do both,
    first...
    ...carry a string "LANGUAGE=POSTSCRIPT" (or similar variations
       with different capitalization) amongst the first 512 bytes,
       *plus*...
    ...contain the "PJL super escape code" amongst the first 128
       bytes ("<1B>%-12345X"). Very likely, most PostScript files
       generated on Windows using a CUPS- or other PPD, will have
       to be auto-typed as "vnd.cups-postscript".
    Probably a file produced with a "Generic PostScript driver"
    will be just "application/postscript" (have not checked).

Once the file is in "application/vnd.cups-postscript" format,
either "pstoraster" or "cupsomatic" will take over (depending
on the printer configuration, as determined by the PPD in use).

NOTE:  a printer queue with *no* PPD associated to it is a "raw"
-----  printer and all files will go directly there as received
        by the spooler; the exeption are file types
"application/octet-stream" which need the mentioned "passthrough
feature" enabled. "Raw" queues don't do any filtering at all, they
hand the file directly to the CUPS backend. This backend is
responsible for the sending of the data to the device (as visible
in the "device URI" notation as lpd://, socket://, smb://, ipp://,
http://, parallel:/, serial:/, usb:/ etc.)

NOTE,  please, also the following fact: "cupsomatic"/Foomatic are
-----  *not* native CUPS drivers and they don't ship with CUPS.
        They are a Third Party add-on, developed at Linuxprinting.org.
As such, they are a brilliant hack to make all models (driven by
Ghostscript drivers/filters in traditional spoolers) also work via
CUPS, with the same (good or bad!) quality as in these other
spoolers. "cupsomatic" is only a vehicle to execute a ghostscript
commandline at that stage in the CUPS filtering chain,  where
"normally" the native CUPS "pstoraster" filter would kick in.
cupsomatic by-passes pstoraster, "kidnaps" the printfile from CUPS
away and re-directs it to go through Ghostscipt. CUPS accepts this,
because the associated CUPS-O-Matic-/Foomatic-PPD carries a line
reading

   *cupsFilter:  "application/vnd.cups-postscript 0 cupsomatic"

This line persuades CUPS to hand the file to cupsomatic, once it
has successfully converted it to the MIME type
"application/vnd.cups-postscript". This conversion will not
happen for Jobs arriving from Windows which are autotyped
"application/octet-stream", with the according changes in
"/etc/cups/mime.types" in place.

See small drawings at the end...

I am not a programmer, so please correct me if I am wrong.

 > With traditional lpr, you can just add "-oraw" to the "print command"
 > line in smb.conf.  With cups, you don't have that alternative.

You *do* have it, I think.

But you need to disable the settings "printing = cups" and "printcap =
= cups" and use "printing = bsd" and "printcap = /etc/printcap"
instead. [Additionally, you will probably have to enable and configure
the CUPS mini-LPD daemon ("cups-lpd") run from inetd... but I have not
checked, so take this item with a grain of salt and a proper dose of
caution, please.]

 > The result is that to support both unix printing and native-driver
 > Windows printing from CUPS, you have to have two logical printers per
 > physical printer: one ("cooked") for Unix clients and one ("raw") for
 > Samba to use.

Yes, that is one current workaround, if you don't want the auto-typing
of CUPS influencing Samba/Windows client PostScript jobs.

CUPS is widely configurable and flexible, even regarding its filtering
mechanism. Another workaround in some situations would be to have
lines in "/etc/cups/mime.types" saying

   application/postscript           application/vnd.cups-raw  0  -
   application/vnd.cups-postscript  application/vnd.cups-raw  0  -

This would prevent all Postscript files to be filtered (or rather, they
will go thru the virtual "nullfilter" denoted with "-". (This could only
be useful for PS printers, or if you want to print PS code on non-PS
printers   ;-)

A single line of

   */*           application/vnd.cups-raw  0  -

would effectively send *all* files towards the backend immediately
(good luck!)

Last, you could have the following (without the need for a Samba
patch):

   application/vnd.cups-postscript  application/vnd.cups-raw  0  my_PJL_stripping_filter

You'd need to write a "my_PJL_stripping_filter" (could be a shellscript)
which parses the PostScript and removes the undesired PJL. This would
need to conform to CUPS filter design (mainly, receive and pass the
parameters printername, job-id, username, jobtitle, copies, printoptions
and possibly the filename). It would just go as world executably into
"/usr/lib/cups/filters/" and work from there, called by cups if it
encounters a MIME type "application/vnd.cups-postscript"

 > The attached patch allows you to specify an option string for cups
 > printers in smb.conf.

I think your patch is in any case very useful (if it works as
advertised  ;-).  It is the most generic, simple and flexible
approach to complement CUPS.

 > So, if you want to use native Windows drivers,
 > all you need is
 >
 >         cups printer options = raw
 >
 > in smb.conf.  You can add any other options that cups and the printer
 > understand.

Now this last sentence makes me very curious. Do you mean you can add
*multiple* options to this directive? Which syntax would be required
for this ?  (Some CUPS options are specified by an "-o option=value"
pair on the commandline, some are single values, like the "-o raw"
one...)

I am thinking on one specific usage now:

-----------------------------------------------------------------------
-> passing any available IPP job attribute to the printer / the spooler
-----------------------------------------------------------------------

For example, CUPS can handle "-o job-hold-until=indefinite". This
keeps the job in the queue "on hold". It will only be printed upon
manual release by the printer operator. This is a requirement in
many "central reproduction departments", where a few operators
manage the jobs of hundreds of users on some big machine, where no
user is allowed to have direct access. (The operators often need to
load the proper paper type before running the 10.000 page job
requested by marketing for the mailing, etc.).

A lot more useful applications come to mind, if I could pass
"any other options that cups and the printer understand" via
the smb.conf directive!!

Thanks a lot!

Cheers,
Kurt

P.S.: List, please give me some feedback, if you think this type of
       explanation could be useful in the Samba HOWTO Collection. In
       that case, I'll try to write it up in a nicer form.


#########################################################################
#
# CUPS in and of itself has this (general) filter chain (CAPITAL
# letters are FILE-FORMATS or MIME types, other are filters (this is
# true for pre-1.1.15 of pre-4.3 versions of CUPS and ESP PrintPro):
#
# <SOMETHNG>-FILEFORMAT
#      |
#      |
#      V
#     <something>tops
#      |
#      |
#      V
# APPLICATION/POSTSCRIPT
#      |
#      |
#      V
#     pstops
#      |
#      |
#      V
# APPLICATION/VND.CUPS-POSTSCRIPT
#      |
#      |
#      V
#     pstoraster   # as shipped with CUPS, independent from any Ghostscipt
#      |           # installation on the system
#      |  (= "postscipt interpreter")
#      |
#      V
# APPLICATION/VND.CUPS-RASTER
#      |
#      |
#      V
#     rasterto<something>  (f.e. Gimp-Print filters may be plugged in here)
#      |   (= "raster driver")
#      |
#      V
# SOMETHING-DEVICE-SPECIFIC
#      |
#      |
#      V
#     backend
#
#
# ESP PrintPro has some enhanced "rasterto<something>" filters as compared to
# CUPS, and also a somewhat improved "pstoraster" filter.
#
# NOTE: Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
#       CUPS and ESP PrintPro plug-in where rasterto<something> is noted.
#
#
#########################################################################
#
# This is how "cupsomatic" comes into play:
# =========================================
#
# <SOMETHNG>-FILEFORMAT
#      |
#      |
#      V
#    <something>tops
#      |
#      |
#      V
# APPLICATION/POSTSCRIPT
#      |
#      |
#      V
#    pstops
#      |
#      |
#      V
# APPLICATION/VND.CUPS-POSTSCRIPT ----------------+
#      |                                          |
#      |                                          V
#      V                                         cupsomatic
#    pstoraster                                  (constructs complicated
#      |  (= "postscipt interpreter")            Ghostscript commandline
#      |                                         to let the file be
#      V                                         processed by a
# APPLICATION/VND.CUPS-RASTER                    "-sDEVICE=<s.th.>"
#      |                                         call...)
#      |                                          |
#      V                                          |
#    rasterto<something>                          V
#      |    (= "raster driver")     +-------------------------+
#      |                            | Ghostscript at work.... |
#      V                            |                         |
# SOMETHING-DEVICE-SPECIFIC         *-------------------------+
#      |                                          |
#      |                                          |
#      V                                          |
#    backend <------------------------------------+
#      |
#      |
#      V
#    THE PRINTER
#
#
#
# Note, that cupsomatic "kidnaps" the printfile after the
# "APPLICATION/VND.CUPS-POSTSCRPT" stage and deviates it through
# the CUPS-external, systemwide Ghostscript installation, bypassing the
# "pstoraster" filter (therefor also bypassing the CUPS-raster-drivers
# "rasterto<something>", and hands the rasterized file directly to the CUPS
# backend...
#
# cupsomatic is not made by the CUPS developers. It is an independent
# contribution to printing development, made by people from
# Linuxprinting.org. (see also http://www.cups.org/cups-help.html)
#
# NOTE: Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
#       CUPS and ESP PrintPro plug-in where rasterto<something> is noted.
#
#
#########################################################################
#
# And this is how it works for ESP PrintPro from 4.3:
# ===================================================
#
# <SOMETHNG>-FILEFORMAT
#      |
#      |
#      V
#     <something>tops
#      |
#      |
#      V
# APPLICATION/POSTSCRIPT
#      |
#      |
#      V
#     pstops
#      |
#      |
#      V
# APPLICATION/VND.CUPS-POSTSCRIPT
#      |
#      |
#      V
#     gsrip
#      |  (= "postscipt interpreter")
#      |
#      V
# APPLICATION/VND.CUPS-RASTER
#      |
#      |
#      V
#     rasterto<something>  (f.e. Gimp-Print filters may be plugged in here)
#      |   (= "raster driver")
#      |
#      V
# SOMETHING-DEVICE-SPECIFIC
#      |
#      |
#      V
#     backend
#
# NOTE: Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
#       CUPS and ESP PrintPro plug-in where rasterto<something> is noted.
#
#
#########################################################################
#
# This is how "cupsomatic" would come into play with ESP PrintPro:
# ================================================================
#
#
# <SOMETHNG>-FILEFORMAT
#      |
#      |
#      V
#    <something>tops
#      |
#      |
#      V
# APPLICATION/POSTSCRIPT
#      |
#      |
#      V
#    pstops
#      |
#      |
#      V
# APPLICATION/VND.CUPS-POSTSCRIPT ----------------+
#      |                                          |
#      |                                          V
#      V                                         cupsomatic
#    gsrip                                       (constructs complicated
#      |  (= "postscipt interpreter")            Ghostscript commandline
#      |                                         to let the file be
#      V                                         processed by a
# APPLICATION/VND.CUPS-RASTER                    "-sDEVICE=<s.th.>"
#      |                                         call...)
#      |                                          |
#      V                                          |
#    rasterto<something>                          V
#      |   (= "raster driver")      +-------------------------+
#      |                            | Ghostscript at work.... |
#      V                            |                         |
# SOMETHING-DEVICE-SPECIFIC         *-------------------------+
#      |                                          |
#      |                                          |
#      V                                          |
#    backend <------------------------------------+
#      |
#      |
#      V
#    THE PRINTER
#
# NOTE: Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
#       CUPS and ESP PrintPro plug-in where rasterto<something> is noted.
#
#########################################################################
#
# And this is how it works for CUPS from 1.1.15:
# ==============================================
#
# <SOMETHNG>-FILEFORMAT
#      |
#      |
#      V
#     <something>tops
#      |
#      |
#      V
# APPLICATION/POSTSCRIPT
#      |
#      |
#      V
#     pstops
#      |
#      |
#      V
# APPLICATION/VND.CUPS-POSTSCRIPT-----+
#                                     |
#                  +------------------v------------------------------+
#                  | Ghostscript                                     |
#                  | at work...                                      |
#                  | (with                                           |
#                  | "-sDEVICE=cups")                                |
#                  |                                                 |
#                  |         (= "postscipt interpreter")             |
#                  |                                                 |
#                  +------------------v------------------------------+
#                                     |
#                                     |
# APPLICATION/VND.CUPS-RASTER <-------+
#      |
#      |
#      V
#     rasterto<something>
#      |   (= "raster driver")
#      |
#      V
# SOMETHING-DEVICE-SPECIFIC
#      |
#      |
#      V
#     backend
#
#
# NOTE: since version 1.1.15 CUPS "outsourced" the pstoraster process to
#       Ghostscript. GNU Ghostscript needs to be patched to handle the
#       CUPS requirement; ESP Ghostscript has this builtin. In any case,
#       "gs -h" needs to show up a "cups" device. pstoraster is now a
#       calling an appropriate "gs -sDEVICE=cups..." commandline to do
#       the job. It will output "application/vnd.cup-raster", which will
#       be finally processed by a CUPS raster driver "rasterto<something>"
#       Note the difference to "cupsomatic", which will *not* output
#       CUPS-raster, but a final version of the printfile, ready to be
#       sent to the printer. cupsomatic also doesn't use the "cups"
#       devicemode in Ghostscript, but one of the classical devicemodes....
#
# NOTE: Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
#       CUPS and ESP PrintPro plug-in where rasterto<something> is noted.
#
#########################################################################
#
# And this is how it works for CUPS from 1.1.15, with cupsomatic included:
# ========================================================================
#
# <SOMETHNG>-FILEFORMAT
#      |
#      |
#      V
#     <something>tops
#      |
#      |
#      V
# APPLICATION/POSTSCRIPT
#      |
#      |
#      V
#     pstops
#      |
#      |
#      V
# APPLICATION/VND.CUPS-POSTSCRIPT-----+
#                                     |
#                  +------------------v------------------------------+
#                  | Ghostscript        . Ghostscript at work....    |
#                  | at work...         . (with "-sDEVICE=           |
#                  | (with              .            <s.th.>"        |
#                  | "-sDEVICE=cups")   .                            |
#                  |                    .                            |
#                  | (CUPS standard)    .      (cupsomatic)          |
#                  |                    .                            |
#                  |          (= "postscript interpreter")           |
#                  |                    .                            |
#                  +------------------v--------------v---------------+
#                                     |              |
#                                     |              |
# APPLICATION/VND.CUPS-RASTER <-------+              |
#      |                                             |
#      |                                             |
#      V                                             |
#     rasterto<something>                            |
#      |   (= "raster driver")                       |
#      |                                             |
#      V                                             |
# SOMETHING-DEVICE-SPECIFIC <------------------------+
#      |
#      |
#      V
#     backend
#
#
# NOTE: Gimp-Print and some other 3rd-Party-Filters (like TurboPrint) to
#       CUPS and ESP PrintPro plug-in where rasterto<something> is noted.
#
##########################################################################

I hope this helps more people understand how CUPS works and how they
can possibly tweak it to their needs.