Available with Production Mapping license.
Summary
Changes the page size of an input map document. Choices for the sizes are the standard ArcMap layouts, as well as a custom option. The orientation can be set to portrait or landscape, and the page units can be set to ArcGIS supported units.
Discussion
Sometimes changes are needed for the layers or layouts of several maps (MXDs). With the SetPageSize function, you don’t have to manage and keep several MXDs synchronized on the server or desktop application. This function can also be used in conjunction with the ApplyLayoutRules function to ensure that the MXD's layout is properly preserved after changing the page size.
Syntax
SetPageSize (map_document, size, {orientation}, {custom_width}, {custom_height}, {page_units})
Parameter | Explanation | Data Type |
map_document | A variable that references a MapDocument object. | Map |
size | The size the page layout can be changed to.
| String |
orientation | The orientation the page layout can be changed to. If the size argument is set to CUSTOM, the orientation parameter is ignored.
| String |
custom_width | The custom page width in page units. If a custom size is selected, the orientation is ignored and this value is used to set the page size. | Double |
custom_height | The custom page height in page units. If a custom size is selected, the orientation is ignored and this value is used to set the page size. | Double |
page_units | Specifies which ArcGIS supported page units the output extent/AOI can be when a custom page size is selected. The default is inches. (The default value is Inches) | String |
Code sample
SetPageSize example 1
This script shows how to set the page layout size by choosing an option from the ArcGIS supported sizes.
import arcpy
import arcpyproduction
# Check out Production Mapping extension
arcpy.CheckOutExtension("foundation")
# Define variables
mxd = arcpy.mapping.MapDocument(r'C:\Project\Project.mxd')
# Set the page size
arcpyproduction.mapping.SetPageSize(mxd, "LEGAL", "LANDSCAPE")
# Check in Production Mapping extension
arcpy.CheckInExtension("foundation")
SetPageSize example 2
This script shows how to set the page layout size with a custom option.
import arcpy
import arcpyproduction
# Check out Production Mapping extension
arcpy.CheckOutExtension("foundation")
# Define variables
mxd = arcpy.mapping.MapDocument(r'C:\Project\Project.mxd')
# Set the page size
arcpyproduction.mapping.SetPageSize(mxd, "CUSTOM", custom_width=60, custom_height=40, page_units="CENTIMETERS")
# Check in Production Mapping extension
arcpy.CheckInExtension("foundation")