I am printing from an rpi3 using nginx+php7.1+cups, connected to a canon printer, which downloads pdf files through https requests. From the rpi3, i issue the following command when something needs to be printed in PHP7.1;
exec(‘lpr -P ‘ . $printer . ‘ -r ‘ . $filename);
The first print (on startup) is fine but any other following requests are printed with garbage letters on the first page in the pdf. The other pages in the same pdf are fine.
When i reboot the rpi3, the first print request is again printed fine, but all following requests have garbage letters on the first page of the pdf.
I have tried restarting cups but that was not the solution. Is there a solution for this?
Update 04/03/2018:
It seems to be a usb problem. When I disconnect/reconnect the usb cable of the printer, the first print is fine, following prints are not. I am now connecting through cups socket (ethernet cable) and each print comes out fine without gibberish characters.
Problem is temporarily solved by connecting with ethernet cable instead of usb cable (tried two different usb cables, different make and short and long).
Any feedback on this matter would be of great help. It seems RPI or CUPS USB is not flushing all data through the usb connection correctly.
Printer model: Canon printer i-sensys lbp 7730.
Cups driver: cups+gutenprint v5.2.10