All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tobias Hoffmann <lprint-list@thax.hardliners.org>
To: Till Kamppeter <till.kamppeter@gmail.com>
Cc: "printing-architecture@lists.linux-foundation.org"
	<printing-architecture@lists.linux-foundation.org>
Subject: Re: [Printing-architecture] Number of copies in pure PDF workflow
Date: Wed, 15 Oct 2014 18:22:55 +0200	[thread overview]
Message-ID: <543E9F5F.8090106@thax.hardliners.org> (raw)
In-Reply-To: <543E72C7.3090603@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1872 bytes --]

On 15/10/14 15:12, Till Kamppeter wrote:
> b) patch cups, namely ppdEmitJCL() in emit.c.
>    As cups does detect PCL as JCL here and sets "JOB NAME", "DISPLAY" or
> "RDYMSG DISPLAY" that would be the best place to add PJL SET COPIES.
>    But this will affect all PPDs with JCL, e.g. when pure PostScript is
> used... and, in case the patch is not accepted upstream, cups-filters
> has to ship it(?)
>
> I will not ship patches for CUPS in the cups-filters upstream package.
> You could post an upstream bug report/feature request on CUPS
> (http://www.cups.org/str.php) to let the ppdEmitJCL() function add "PJL
> SET COPIES=X" with the number of copies taken from the command line
> arguments (4th argument, see "man filter").

Patching upstream would unfortunately require changing the function 
signature of ppdEmitJCL() -- or adding a new ppdEmitJCL2 function. And 
that would be for a deprecated API...

> We must look into whether we
> should generally add "PJL SET COPIES=X", or only under certain
> conditions (is another copy generation method supposed to be used?
> Should we have some PPD keyword to turn it on or off?).

I don't know...?

>
>> c) do not use ppdEmitJCL at all. We would loose e.g. JOB NAME, but have
>> better control over the output...
> Do you mean using the not very elegant method to copy the code of the
> function into cups-filters and modify it there?

Simply put ... yes.


> 2. setting ppd->jcl_ps=concat("...SET COPIES...\n",
> JCLToPDFInterpreter->value)
Attached a (untested) first patch to pdftopdf:
param.deviceCopies will always be 1 for ppd->manual_copies, so SET 
COPIES is only inserted when *cupsManualCopies is not set and more than 
1 copy is requested.

Please review.

> Also make the above-mentioned feature request for CUPS to discuss the
> SET COPIES in the ppdEmitJCL() of CUPS.
>
See my comment above.

   Tobias


[-- Attachment #2: pjlcopies-v1.patch --]
[-- Type: text/x-patch, Size: 1450 bytes --]

--- filter/pdftopdf/pdftopdf_jcl.cc	2012-10-18 17:03:24 +0000
+++ filter/pdftopdf/pdftopdf_jcl.cc	2014-10-15 16:01:41 +0000
@@ -128,6 +128,8 @@
   ppdEmit(ppd,stdout,PPD_ORDER_EXIT);
 
   if (param.emitJCL) {
+     char *old_jcl_ps = ppd->jcl_ps;
+
     /* pdftopdf only adds JCL to the job if the printer is a native PDF
        printer and the PPD is for this mode, having the "*JCLToPDFInterpreter:"
        keyword. We need to read this keyword manually from the PPD and replace
@@ -136,13 +138,23 @@
        "*JCLToPDFInterpreter:". */
     ppd_attr_t *attr;
     if ( (attr=ppdFindAttr(ppd,"JCLToPDFInterpreter",NULL)) != NULL) {
-      ppd->jcl_ps=strdup(attr->value);
-      ppd_decode(ppd->jcl_ps);
+      if ( (param.deviceCopies>1)&&(strncmp(ppd->jcl_begin, "\033%-12345X@", 10)==0) ) { // PJL
+        const size_t size=strlen(attr->value)+1+30;
+        ppd->jcl_ps=(char *)malloc(size*sizeof(char));
+        snprintf(ppd->jcl_ps, size, "@PJL SET COPIES=%d\n%s",param.deviceCopies,attr->value);
+        ppd_decode(ppd->jcl_ps); // will not change SET COPIES
+      } else {
+        ppd->jcl_ps=strdup(attr->value);
+        ppd_decode(ppd->jcl_ps);
+      }
     } else {
       ppd->jcl_ps=NULL;
     }
     ppdEmitJCL(ppd,stdout,param.jobId,param.user,param.title);
     emitJCLOptions(stdout,ppd,param.deviceCopies);
+
+    free(ppd->jcl_ps);
+    ppd->jcl_ps = old_jcl_ps; // cups uses pool allocator, not free()
   }
 }
 // }}}


  parent reply	other threads:[~2014-10-15 16:22 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-03 19:28 [Printing-architecture] Number of copies in pure PDF workflow Alex Korobkin
2014-10-03 19:49 ` Ira McDonald
2014-10-03 20:23   ` Alex Korobkin
2014-10-04 15:40 ` Michael Sweet
2014-10-04 17:36   ` Alex Korobkin
2014-10-04 19:47     ` Tobias Hoffmann
2014-10-05  4:58       ` Alex Korobkin
2014-10-04 19:48     ` Michael Sweet
2014-10-05  5:03       ` Alex Korobkin
2014-10-06 14:12         ` Michael Sweet
2014-10-06 15:07           ` Alex Korobkin
2014-10-06 15:32             ` Michael Sweet
2014-10-06 15:55               ` Alex Korobkin
2014-10-06 16:01                 ` Michael Sweet
2014-10-07 11:49               ` Till Kamppeter
2014-10-07 11:55                 ` Michael Sweet
2014-10-07 12:12                   ` Till Kamppeter
2014-10-06 12:54       ` Till Kamppeter
2014-10-06 14:06         ` Alex Korobkin
2014-10-07 14:06           ` Alex Korobkin
2014-10-07 20:03           ` Till Kamppeter
2014-10-07 21:18             ` Alex Korobkin
2014-10-07 21:45               ` Tobias Hoffmann
2014-10-08  2:53                 ` Alex Korobkin
2014-10-08  9:57                 ` Till Kamppeter
2014-10-08 14:40                   ` Tobias Hoffmann
2014-10-08 19:41                     ` Alex Korobkin
2014-10-08 20:53                       ` Tobias Hoffmann
2014-10-10 18:38                         ` Alex Korobkin
2014-10-10 20:06                           ` Tobias Hoffmann
2014-10-10 20:58                             ` Till Kamppeter
2014-10-14 19:17                               ` Alex Korobkin
2014-10-14 21:09                                 ` Tobias Hoffmann
2014-10-15 10:50                                   ` Tobias Hoffmann
2014-10-15 13:12                                     ` Till Kamppeter
2014-10-15 15:04                                       ` Till Kamppeter
2014-10-15 16:17                                       ` Till Kamppeter
2014-10-15 19:28                                         ` Tobias Hoffmann
2014-10-16 15:53                                           ` Till Kamppeter
2014-10-16 16:52                                           ` Alex Korobkin
2014-10-16 20:59                                             ` Tobias Hoffmann
2014-10-17 16:22                                               ` Alex Korobkin
2014-10-17 16:40                                                 ` Till Kamppeter
2014-10-20 16:23                                                   ` Alex Korobkin
2014-10-20 16:29                                                     ` Till Kamppeter
2014-10-20 17:28                                                       ` Alex Korobkin
2014-10-20 20:30                                                         ` Till Kamppeter
2014-10-20 21:18                                                           ` Alex Korobkin
2014-10-15 16:22                                       ` Tobias Hoffmann [this message]
2014-10-15 17:06                                         ` Alex Korobkin
2014-10-15 19:02                                           ` Tobias Hoffmann
2014-10-15 19:16                                             ` Tobias Hoffmann
2014-10-07 22:40             ` Michael Sweet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=543E9F5F.8090106@thax.hardliners.org \
    --to=lprint-list@thax.hardliners.org \
    --cc=printing-architecture@lists.linux-foundation.org \
    --cc=till.kamppeter@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.