Delete print jobs from the spooler

Official translation unavailable. Translate this page with Google:

Problem

You would like to print your labels, but there are already other print jobs in the spooler you don't want to print. Before printing, you would like to delete all the existing print jobs in the spooler.

 

Solution

Solution 1

Some NiceLabel drivers have an option to delete print jobs before you print.

  1. In your Windows Settings open Printers & scanners.

  2. Click the printer you would like to delete print jobs before printing, then click the Manage button.

  3. Click Printing preferences.

  4. The Printing preferences window opens. Go to the Print Options tab and enable the Cancel all current and queued printing documents option (if available for your printer).

    img-01_cancel_print_jobs.png
Solution 2

Send a custom command to your printer to clear printer memory:

  • In Printing Preferences go to Printer Settings > Custom Commands > Before print job section. In Type drop-down menu select Parsed text and enter the command to clear printer memory in the Contents edit field.

    27_printer_command1.png

    Note

    Each printer brand uses its own printer language (commands). See your printer manual for the exact command.

  • You can send printer commands also with PowerForms or Automation using the following actions:

    • Send Data to Printer

    • Send Data to TCP/IP port (if you use a network printer)

    • Send Data to Serial port (if you use a printer with COM port)

Solution 3

You can use Python script in NiceLabel solutions to delete print jobs from the spooler.

Here is the sample code:

def purgePrintJobs(printerName):
    import clr
    clr.AddReference("System.Printing")
    from System.Printing import (PrintQueue, LocalPrintServer, PrintSystemDesiredAccess)
    clr.AddReference("System.Management")
    from System.Management import (ManagementScope, ManagementObject, ManagementObjectSearcher, ManagementPath, SelectQuery)      
      
    try:
        printServer = LocalPrintServer()      
        printQueue = PrintQueue(printServer, printerName, PrintSystemDesiredAccess.AdministratePrinter)
        printQueue.Purge()        
        return ""
    except Exception as e:
        return "Clearing print queue for '{}' failed with error '{}'!".format(printerName, e.message)        
      
DeleteSpooler.Value = purgePrintJobs("My printer")  

In the last line of code replace "My printer" with the actual printer name. Your solution must also contain the variable DeleteSpooler.