c++printingqueuecups

cups printing multiple files from c++ using intermediate file


I am trying to send a very large image to a custom printer. Due to memory restrictions and the fact that he image is processed as full color, The image has to be chunked in smaller sections to be sent to printer. Since not all images will have same size (or feed/cutMedia options), I have to print them separately, each with its own option set

jobId = cupsPrintFile(...) for each image (instead of jobId = cupsPrintFiles)

If multiple jobs are sent to the printer or multiple users are sending jobs, there is a risk that those jobs will go between the chunks from current job.

The only solution I can come up with, is to send the print jobs to a file instead of the printer, using all the options (and going through all the filters), then take all the print jobs created and send them as a batch to the printer, with a single jobId...

Are both of these steps possible ?

I can "print to file" if I set

lpoptions -o File="/home/me/abcd.prn"

....but...

1) How do I do this through c++ code ?

2) How do I make this happen to different files abcd1.prn, abcd2.prn, abcd3.prn during the same print session ?

3) How do I send the files abcd1.prn, abcd2.prn, abcd3.prn to the REAL printer during the same print session through c++ code ? As a single job ?

Are any of the steps above possible ?

My thought - create a backend to print to a file - then another backend to get the files to a printer ?


Solution

  • I used the 2dir backend, from here and then read and concatenated the files - getting either a file that would look like "print to file", or that could be sent to printer in a single job.

    To send to the custom backend, I used a cups option - and also created a script run through the code to install a printer that used the 2dir backend, if it was not installed.