[Python] Reasons Printing Via a Socket Connection Would Fail

Discussão em 'Python' iniciado por Stack, Julho 28, 2025.

  1. Stack

    Stack Membro Participativo

    I am writing a program that involves printing Raw Printer Command Language (PCL) files wrapped in Print Job Language (PJL) commands. I print it via a port 9100 socket connection to the printer using its IP address. I had it printing just fine the other day but these past few days when I have tested the program nothing prints. It doesn't even add a job to the print queue. Are there any reasons why printing via a socket connection would start failing like this? I didn't change any of the code related to printing and tested it with my socket print test file that also used to work and I got the same thing. I am getting no errors the data is sent out and the program proceeds. Any help or advice would be greatly appreciated.

    Code:

    with open(pcl_path, "rb") as file: # opens PCL file to read in data
    data = file.read()
    with socket.create_connection((printer_ip, PORT)) as sock:
    # sends raw binary print data over the connection
    sock.sendall(data)


    There is error handling to go with this and logging messages but I left them out for the sake of clarity.

    Continue reading...

Compartilhe esta Página