Python Win32print Job Status

前端 未结 2 1104
醉梦人生
醉梦人生 2021-01-13 22:36

I have been trying to get the status of a print job using win32print in Python.

The status codes provided by win32print don\'t seem to match the status code for the

相关标签:
2条回答
  • 2021-01-13 23:05

    You can start here:

    This script allows you to see your printing job queue. You can customize it using the Get Job documentation if you want to see the information of a specific Job.

    import time
    import win32print
    
    #----------------------------------------------------------------------
    def print_job_checker():
        """
        Prints out all jobs in the print queue every 5 seconds
        """
        jobs = [1]
        while jobs:
            jobs = []
            for p in win32print.EnumPrinters(win32print.PRINTER_ENUM_LOCAL,
                                             None, 1):
                flags, desc, name, comment = p
    
                phandle = win32print.OpenPrinter(name)
                print_jobs = win32print.EnumJobs(phandle, 0, -1, 1)
                if print_jobs:
                    jobs.extend(list(print_jobs))
                for job in print_jobs:
                    print "printer name => " + name
                    document = job["pDocument"]
                    print "Document name => " + document
                win32print.ClosePrinter(phandle)
    
            time.sleep(5)
        print "No more jobs!"
    
    #----------------------------------------------------------------------
    if __name__ == "__main__":
        print_job_checker()
    

    Script taken from this post

    0 讨论(0)
  • 2021-01-13 23:08

    The returned status is a bit mask, as described here , for example . Multiple values ​​can be OR'ed, so your value of 8208(hex 0x00002010) indicates that the printer has (all) status.

    • hex 0x00002000 = PRINTER_STATUS_WAITING
    • hex 0x00000010 = PRINTER_STATUS_PAPER_OUT
    0 讨论(0)
提交回复
热议问题