# CUPS PPD file - Custom Modifications



## JCF (Aug 25, 2016)

To whom it may concern,

We have a solution in place, where we have customized the PPD file to add a watermark, or document classification stamp to each document printed.

This is already working, with all PostScript enabled printers.

If I print a test page from within CUPS, the watermark, and all of the extra logging that I scripted, all work as intended.

But, my primary application is sending raw PCL code to the printers, and with one particular print job, there is something inside of the PCL code that is causing CUPS to not print the watermark.

Actually, it appears as if the watermark routine is not even being called.

I know that using the "-l" option as an argument to the LPR command, will suppress all extra CUPS formatting.  But, there is no "-l" option included with the LPR command in this case.

So, I must assume that the PCL code is sending something, to suppress the custom watermark solution.

When I print from this application routine, the print job prints just fine, but it suppresses the watermark routine.

The only way I can see this happening, is if the PPD file isn't even being read in.

The CUPS log files do not show any errors... They all show that the printed jobs are going through successfully.  Which is true... They are just not adding the watermark...

If the watermark routine is called, it actually creates a temporary directory, where I dump the output to a postscript.in file, a conversion file to both PDF and plain text, and additional logging... All for debugging purposes...

In this case, the watermark routine is NOT being called.  No temporary directory is created, and no files are being created.

Here is my question:

Is there some way to add EXTRA logging, to see whether the PPD file is being read, or whether the PCL code is causing the PPD file to be overlooked?

Maybe an extra option to the LPR command, to cause verbose output to a separate log file?

Thanks in advance, and have a great day...

JCF


----------



## shepper (Aug 25, 2016)

Most applications generate postscript (ps).  PCL only printers need to convert ps to pcl  (See section 9.3 of the FreeBSD handbook).  It is possible to embed a watermark at the postscript level.


----------



## JCF (Aug 25, 2016)

Hi shepper,

Yes, we are already embedding the watermark at the postscript level.  I developed this solution more than a year ago, and we have been using it for the past year already.

But, we need to create application level printer drivers, called "subtypes" inside of our application.

One of our more senior / advanced developers gave me a huge string of PCL code to insert inside of this application level printer driver.

Since putting this latest embedded PCL code into place, the reports are printing with the exact specifications we need, but something inside of the PCL code caused the watermark to stop being added.

I need to determine what that is... And, if there is some way to increase the logging, before it gets to the point where the PPD file is called, I need to see if we can do that...


----------



## shepper (Aug 25, 2016)

I'm not an expert but it seems redundant to have an embedded watermark in ps and then have a second code base in pcl to add the same watermark.  I'm wondering what happens if you print the document via cups to a pdf file?  Does the watermark show up in the *pdf and if you subsequently print the pdf?


----------



## JCF (Aug 25, 2016)

Hi shepper,

Sorry, but there is no watermark added from within the PCL code. 

The watermark is merged with the final printed document. 

The Watermark "code" or "script" is called from within the PPD file, as an external routine.

When you create a new postscript printer inside of CUPS, it creates a local PPD file.

We have separate, external scripts, that massage the incoming print jobs, merging the watermark file with the printed document.

In order to call these external scripts, we need to add a single line, manually, inside of the PPD file.

If the PPD file is called, it always runs the externally called scripts, and it always adds the watermark.

I know from experience, that if we use the "-l" option with the LPR command, it suppresses the watermark creation.

But, we are not using the "-l" option with LPR.

The only thing that has changed, is the PCL code, inside of the application itself.

This PCL code controls margins, characters per inch, lines per inch, lines per page, form feeds, and various other document specific formatting.

If your printer is configured to use a postscript driver in CUPS, CUPS automatically converts all incoming print requests to postscript, regardless of how it was sent to CUPS.  That includes MS Word, Excel, Powerpoint, PDF, or any other known, printable format.

But, there must be something inside of the new PCL code, supplied by this senior developer, that is causing CUPS to not use the PPD file.

In other words, something in the PCL code is causing the print job to ignore the PPD file, just as the "-l" option would do, using the LPR command.

I need to know if there is some way to log, or capture, the commands that are being sent to the CUPS server.

I need to find out what code is causing CUPS to bypass the PPD file.

JCF


----------



## JCF (Aug 25, 2016)

Inside of the PPD file, the one line entry that we add is:

          *cupsFilter: "application/vnd.cups-postscript 100 /usr/lib/cups/filter/watermark"

But, in the log files, it shows the following entry is what is being called:

          Request file type is application/vnd.cups-raw.

There is no vnd.cups-raw in the PPD file, so something in the PCL code is generating this logfile entry.

Something in the PCL code is causing the job to print using the "vnd.cups-raw" option, bypassing the PPD file.

JCF


----------



## shepper (Aug 25, 2016)

I may be adding to the confusion.  FreeBSD base installs provide an older, non-cups, printing spooler that also has an lpr command.  I use the native lpr printing system with a postscript capable printer.  My operating procedure with native lpr printing is to generate the postscript file and print that directly.  So if I wanted a watermark, it would need to be generated in the postscript file which is then sent directly to the printer.     Because I do not use cups, I cannot address your question directly regarding the commands sent to the cups server - sorry.

I recall a prior Thread 53725 where there was an issue running a print job through cups-filter twice: print job -> client cups -> server cups.  I wonder if 
	
	



```
/usr/lib/cups/filter/watermark
```
 is trying to avoid avoid going through cups-filter a second time?


----------



## Skarps (Apr 20, 2022)

JCF, I'm planning on writing a similar custom Watermark PPD for my printer. However I cannot find any examples on how to do that. How do you add a watermark image file and how do you combine it with all the printed pages? Can you upload your ppd / custom filter as an example?


----------

