# CUPS prints n² as many copies as I want

This has baffled me for a few weeks now. I have a Kyocera network printer set up in CUPS, and whenever I try to print to it I seem to end up with n² as many copies as I request. That is,

• I try to print 2 copies of a document and I get 4
• I try to print 5 copies of a document and I get 25
• I try to print 60 copies of a document unattended, it runs out of paper, and I wander around the building depositing the extra copies in many recycling bins so as not to implicate myself too directly as the culprit

I cannot begin to imagine how to diagnose this, but besides being mildly amusing it does mean that to get my desired 60 copies of a document I have to go to some esoteric lengths (e.g. print 7 copies, print 3 copies, print 1 copy two times) which was amusing at first but has quickly gotten old.

So I am posting here in the hopes that someone can reassure me that I am not crazy, and hope that maybe someone might have experienced this before and know of a way to fix it?

I am printing a PDF from Document Viewer 3.18.2

• +1 It sounds like your software sends N times a request to the printer for N copies of your doc! Feb 25, 2016 at 12:34
• "...to get my desired 60 copies of a document I have to go to some esoteric lengths (e.g. print 7 copies, print 3 copies, print 1 copy two times) which was amusing at first but has quickly gotten old." Clearly the solution is to fob the mathematics off onto a computer program. Luckily, Wolfram Alpha knows how to calculate the answer for you: give it "60 sum of squares" and you get back three solutions, one of which is the 7² + 3² + 1² + 1² solution you came up with on your own. Problem solved. :) Apr 16, 2016 at 22:42
• Incidentally, by Lagrange's four-square theorem, every positive integer is the sum of four squares. Jun 29, 2016 at 14:43
• I don't have the answer, but given that you consistently get n² copies suggests that you have a pipeline in which more than one member is performing the 'xn' operation and (at least the first of those) is not removing that option as it processes it. Perhaps that helps you diagnose the problem? Jun 29, 2016 at 16:21
• @richard : 9 = 3^2 + 0^2 + 0^2 + 0^2. Jul 10, 2016 at 7:54

FWIW, I had the very same issue with a Brother QL-1050 label printer, under Debian Sid. It was not an application bug as suggested in comments, but a CUPS/driver issue. You can confirm this by running `lp` or `lpr` and see if it is affected as well :

``````lp -d YOURPRINTER -n 2 /some/file.pdf
lpr -P YOURPRINTER -# 2 /some/file.pdf
``````

I managed to solve the problem by editing `/usr/lib/cups/filter/brother_lpdwrapper_ql1050`, and modifying the line

``````CUPSOPTION=`echo "\$5 Copies=\$4" | sed -e …
``````

into

``````CUPSOPTION=`echo "\$5" | sed -e …
``````

(`Copies=1` also works).

I guess the number of copies was feeded twice somehow.

There must be a similar file for your printer, and though I guess the name and definition of `CUPSOPTION` may vary, those options are probably defined there.

• Hi, I stumbled upon this exact problem, however, I can't find any CUPSOPTION variable in the filter file. The setup is somewhat more complicated because the printer is shared over network and configured as a "Raw" printer on the host while being configured properly on the client. So I assume that the filter file in question is the one on the client. Here is its content: pastebin.com/1gf1jdC9 Running the lp command in your answer on the client prints 4 copies, running it on the host prints nothing (since the printer is configured as "Raw" there). Any ideas what could be wrong here? Thx! Dec 25, 2018 at 21:04
• @Photon I had a look at your pastebin, but I'm afraid I can't be of much help. Good luck. Dec 25, 2018 at 21:33
• Thanks for the quick reply! I'll post in case I figure it out, I'm somewhat pessimistic yet though. :) Dec 25, 2018 at 21:38
• I'm having the same problem. How do you work out which filter file to modify? Also, FWIW, `grep CUPSOPTION -r /usr/lib/cups/filter` is empty on my system. Jul 30, 2019 at 2:16
• thankyou very much, this worked for me with a brother ql570 printer Apr 16, 2020 at 11:54

As you are using "Document Viewer 3.18.2" (which seems to be an Android application: https://play.google.com/store/apps/details?id=org.sufficientlysecure.viewer), may I suggest you try printing from a Windows and then a Linux PC connected to the printer.

With Windows it will check whether the config at printer end is OK. With Linux you can check the CUPS settings. On the Linux side, try printing with both a viewer like Evince and the command line. For command line printing the page at: https://www.cups.org/doc/options.html gives a lot of information.

• Document Viewer 3.18.2 is a Linux application.
– Mala
Sep 27, 2017 at 14:57
• "Document viewer" is as Evince introduce itself to the user. Nov 12, 2019 at 10:09