Book Image

Programming ArcGIS with Python Cookbook, Second Edition

By : Donald Eric Pimpler, Eric Pimpler
Book Image

Programming ArcGIS with Python Cookbook, Second Edition

By: Donald Eric Pimpler, Eric Pimpler

Overview of this book

Table of Contents (22 chapters)
Programming ArcGIS with Python Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Getting a list of available printers


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.

Getting ready

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.

How to do it…

Follow these steps to learn how to use the ListPrinterNames() function to return a list of the available printers for your script:

  1. Open C:\ArcpyBook\Ch4\Crime_Ch4.mxd in ArcMap.

  2. Open the Python window.

  3. Import the arcpy.mapping module:

    import arcpy.mapping as mapping
  4. Reference the currently active document (Crime_Ch4.mxd) and assign this reference to a variable:

    mxd = mapping...