Yet another list function provided by arcpy
is ListPrinterNames()
, which generates a list of the available printers. As is the case with the other list functions that we've examined, ListPrinterNames()
is often called a preliminary step in a multistep script.
Before printing maps with the PrintMap()
function, it is a common practice to call the ListPrinterNames()
function, which returns a list of the available printers for the local computer. A particular printer can then be found by iterating the list of printers and using it as an input for the PrintMap()
function.
Follow these steps to learn how to use the ListPrinterNames()
function to return a list of the available printers for your script:
C:ArcpyBookCh4Crime_Ch4.mxd
in ArcMap.arcpy.mapping
module:import arcpy.mapping as mapping
Crime_Ch4.mxd
) and assign this reference to a variable:mxd = mapping.MapDocument("CURRENT")
ListPrinterNames()
function and print each printer:for printerName in mapping.ListPrinterNames(): print(printerName)
c:ArcpyBookcodeCh4GetListOfPrinters.py
solution file.HP Photosmart D110 series HP Deskjet 3050 J610 series (Network) HP Deskjet 3050 J610 series (Copy 1) HP Deskjet 3050 J610 series Dell 968 AIO Printer