pycups icon indicating copy to clipboard operation
pycups copied to clipboard

printFile do not work

Open XiaofanFTD opened this issue 2 years ago • 1 comments

link = 'http://example.pdf' conn = cups.Connection() printers = conn.getPrinters() printer_name = list(printers.keys())[0] print(printers) print(printer_name) print(link) resp = requests.get(link) content = resp.content temp = tempfile.NamedTemporaryFile(delete=False, suffix='.pdf') try: temp.write(content) temp.seek(0) job_attrs = { 'print-color-mode': 'monochrome', 'copies': '2', 'document-format': cups.CUPS_FORMAT_AUTO,

        # 'document-format': 'application/pdf',
    }
    print(temp.name)
    job_id = conn.printFile(printer_name, temp.name, 'label11111', job_attrs)
    while True:
        job_status = conn.getJobAttributes(job_id)
        job_state = job_status.get('job-state')

        if job_state is None:
            print(f"Job {job_id} not found in the queue.")
            break
        elif job_state == 9:
            print(f"Job {job_id} status: completed")
            break
        else:
            print(f"Job {job_id} status: {job_state}")
            time.sleep(1)
    temp.close()
except Exception as e:
    print(f"An error occurred: {e}")
finally:
    temp.close()

out: Job 198 status: 5 Job 198 status: 5 Job 198 status: 5 Job 198 status: completed

but no printed

XiaofanFTD avatar Apr 19 '23 06:04 XiaofanFTD

Hi,

turn on debug logging in cups by cupsctl LogLevel=debug2, reproduce again and attach the log file or journal logs in file with .txt suffix (this way github accepts files).

This can be issue with your CUPS setup and debug logs can tell us more.

zdohnal avatar Apr 19 '23 07:04 zdohnal