Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printFile do not work #52

Open
XiaofanFTD opened this issue Apr 19, 2023 · 1 comment
Open

printFile do not work #52

XiaofanFTD opened this issue Apr 19, 2023 · 1 comment

Comments

@XiaofanFTD
Copy link

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

@zdohnal
Copy link
Member

zdohnal commented Apr 19, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants