ExportToPDF (arcpy.mapping)

Zusammenfassung

Exports the page layout or data frame of a map document (.mxd) to the Portable Document Format (PDF).

Diskussion

PDF files are designed to be consistently viewable and printable across different platforms. They are commonly used for distributing documents on the Web and are becoming a standard interchange format for content delivery. ArcMap PDFs are editable in many graphics applications and retain annotation, labeling, and attribute data for map layers from the ArcMap table of contents. PDF exports from ArcMap support embedding of fonts and thus can display symbology correctly even if the user does not have Esri fonts installed. PDF exports from ArcMap can define colors in CMYK or RGB values.

To export a single data frame instead of the entire page layout, pass a DataFrame object to the function's data_frame parameter. Because data frame exports do not have an associated page to provide height and width information, you must provide this via the df_export_width and df_export_height parameters.

Controlling graphic quality of the generated image differs for page layout exports versus data frame exports. When exporting a page layout, control image detail by changing the resolution parameter. When exporting a data frame, keep the resolution parameter at its default value, and change the df_export_width and df_export_height parameters to alter image detail. The height and width parameters directly control the number of pixels generated in the export file and are only used when exporting a data frame. Images with larger numbers of pixels will have higher image detail. For most page layout exports, the default parameter values should generate good results and nice looking export images on the first try. For data frame exports, you may need to experiment with the df_export_width and df_export_height values a few times before getting the result you want.

Refer to the Exporting your map topic in ArcGIS Help for more detailed discussions on exporting maps.

Syntax

ExportToPDF (map_document, out_pdf, {data_frame}, {df_export_width}, {df_export_height}, {resolution}, {image_quality}, {colorspace}, {compress_vectors}, {image_compression}, {picture_symbol}, {convert_markers}, {embed_fonts}, {layers_attributes}, {georef_info}, {jpeg_compression_quality})
ParameterErläuterungDatentyp
map_document

A variable that references a MapDocument object.

MapDocument
out_pdf

A string that represents the path and file name for the output export file.

String
data_frame

A variable that references a DataFrame object. Use the string/constant "PAGE_LAYOUT" to export the map document's page layout instead of an individual data frame.

(Der Standardwert ist PAGE_LAYOUT)

Object
df_export_width

A number that defines the width of the export image in pixels for a data frame export. df_export_width is only used when exporting a data frame. Exporting a page layout uses the map document page width instead of df_export_width.

(Der Standardwert ist 640)

Integer
df_export_height

A number that defines the height of the export image in pixels for a data frame export. df_export_height is only used when exporting a data frame. Exporting a page layout uses the map document page height instead of df_export_height.

(Der Standardwert ist 480)

Integer
resolution

A number that defines the resolution of the export file in dots per inch (DPI).

(Der Standardwert ist 300)

Integer
image_quality

A string that defines output image quality, the draw resolution of map layers that draw as rasters.

  • BESTAn output image quality resample ratio of 1.
  • BETTERAn output image quality resample ratio of 2.
  • NORMALAn output image quality resample ratio of 3.
  • FASTERAn output image quality resample ratio of 4.
  • FASTESTAn output image quality resample ratio of 5.

(Der Standardwert ist BEST)

String
colorspace

A string that defines the colorspace of the export file. Valid values are CYMK and RGB.

  • CMYKCyan, Magenta,Yellow, and blacK color model.
  • RGBRed, Green, and Blue color model.

(Der Standardwert ist RGB)

String
compress_vectors

A Boolean that controls compression of vector and text portions of the output file. Image compression is defined separately.

(Der Standardwert ist True)

Boolean
image_compression

A string that defines the compression scheme used to compress image or raster data in the output file.

  • ADAPTIVEAutomatically selects the best compression type for each image on the page. JPEG will be used for large images with many unique colors. DEFLATE will be used for all other images.
  • JPEGA lossy data compression.
  • DEFLATEA lossless data compression.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • RLERun-length encoded compression.

(Der Standardwert ist ADAPTIVE)

String
picture_symbol

A string that defines whether picture markers and picture fills will be converted to vector or rasterized on output.

  • RASTERIZE_BITMAP Rasterize layers with bitmap markers/fills.
  • RASTERIZE_PICTURERasterize layers with any picture marker/fill.
  • VECTORIZE_BITMAPVectorize layers with bitmap markers/fills.

(Der Standardwert ist RASTERIZE_BITMAP)

String
convert_markers

A Boolean that controls the coversion of character-based marker symbols to polygons. This allows the symbols to appear correctly if the symbol font is not available or cannot be embedded. However, setting this parameter to True disables font embedding for all character-based marker symbols, which can result in a change in their appearance.

(Der Standardwert ist False)

Boolean
embed_fonts

A Boolean that controls the embedding of fonts in the export file. Font embedding allows text and character markers to be displayed correctly when the document is viewed on a computer that does not have the necessary fonts installed.

(Der Standardwert ist True)

Boolean
layers_attributes

A string that controls inclusion of PDF layer and PDF object data (attributes) in the export file.

  • LAYERS_ONLYExport PDF layers only.
  • LAYERS_AND_ATTRIBUTESExport PDF layers and feature attributes.
  • NONENone.

(Der Standardwert ist LAYERS_ONLY)

String
georef_info

A Boolean that enables the export of coordinate system information for each data frame into the output PDF file.

(Der Standardwert ist True)

Boolean
jpeg_compression_quality

A number that controls compression quality value when image_compression is set to ADAPTIVE or JPEG. The valid range is 1 to 100. A jpeg_compression_quality of 100 provides the best quality images but creates large export files. The recommended range is between 70 and 90.

(Der Standardwert ist 80)

Integer

Codebeispiel

ExportToPDF example 1

This script opens a map document and exports the page layout to a PDF file using default values for all options.

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
arcpy.mapping.ExportToPDF(mxd, r"C:\Project\Output\Project.pdf")
del mxd
ExportToPDF example 2

This script will export a single data frame instead of the entire page layout, similar to exporting from data view in the ArcMap application. The default values for df_export_width and df_export_height are 640 and 480. By passing larger values for these parameters, we are able to produce an output image with higher detail.

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Transportation")[0]
arcpy.mapping.ExportToPDF(mxd, r"C:\Project\Output\ProjectDataFrame.pdf", df,
                          df_export_width=1600,
                          df_export_height=1200)
del mxd
9/11/2013