0

I have a printer connected to raspberry pi and I want to print a .xlxs file which is in raspberry pi using python or php .I have tried CUPS and libreoffice.By using CUPS i did able to print txt file but not any other file using python using below code..

import cups
conn = cups.Connection()
printers = conn.getPrinters()
printer_name = printers.keys()[0]
conn.printFile(printer_name,'path to file',"",{})

By using libreoffice and subprocess i can print .xlxs file but only when i run python file directly and not able to print when python file is executed by php file.

subprocess.call('libreoffice --pt <printername> <path to file>',shell=True)

So which method to follow to print file?

rahul
  • 58
  • 8
  • 1
    Refer to this [answer](https://stackoverflow.com/a/57523076/6521116) for php to read a xlxs file. – LF00 Sep 16 '19 at 11:48
  • I don't want to read file, I have to print it. – rahul Sep 16 '19 at 12:04
  • 2
    No way to print a file without read it. – LF00 Sep 16 '19 at 12:06
  • I mean I don't want to see the file with my eyes and I have not connected any display to the pi I am triggering the print using PHP script and also I have not only simple data but I have tables in xlxs file. – rahul Sep 17 '19 at 03:19

0 Answers0