ExportToPDF (arcpy.mapping)

摘要

以便携文档格式 (PDF) 导出地图文档 (.mxd) 的页面布局或数据框。

讨论

PDF 文件可在不同的平台上实现一致的查看和打印效果。它们通常用于在 Web 上分发文档,并且此格式现在为内容传送的标准交换格式。ArcMap PDF 在许多图形应用程序中均可编辑,并且它还保留了 ArcMap 内容列表中地图图层的注记、标注和属性数据。从 ArcMap 中导出的 PDF 支持嵌入字体,因此即使用户尚未安装 Esri 字体也可以正确地显示符号。从 ArcMap 中导出的 PDF 可以通过 CMYK 值或 RGB 值定义颜色。

要导出单个数据框(而不是整个页面布局),可将 DataFrame 对象传给函数的 data_frame 参数。由于数据框导出不具有可提供高度和宽度信息的关联页面,所以必须通过 df_export_widthdf_export_height 参数来提供此信息。

对于页面布局导出和数据框导出,控制生成图像图形质量的方式有所不同。导出页面布局时,通过更改 resolution 参数来控制图像细节。导出数据框时,保持 resolution 参数的默认值,更改 df_export_widthdf_export_height 参数来更改图像细节。高度和宽度参数直接控制在导出文件中生成的像素数,且仅在导出数据框时使用。像素数较高的图像具有较高的图像细节。对于大多数页面布局导出,默认参数值应在第一次尝试时生成良好的结果和美观的导出图像。对于数据框导出,您可能需要对 df_export_widthdf_export_height 值进行若干次试验,之后才能得到理想的结果。

有关导出地图的详细信息,请参阅 ArcGIS 帮助中的导出地图主题。

语法

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})
参数说明数据类型
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.

(默认值为 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.

(默认值为 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.

(默认值为 480)

Integer
resolution

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

(默认值为 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.

(默认值为 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.

(默认值为 RGB)

String
compress_vectors

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

(默认值为 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.

(默认值为 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.

(默认值为 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.

(默认值为 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.

(默认值为 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.

(默认值为 LAYERS_ONLY)

String
georef_info

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

(默认值为 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.

(默认值为 80)

Integer

代码实例

ExportToPDF 示例 1

此脚本使用所有选项的默认值打开地图文档并将页面布局导出为 PDF 文件。

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

与从 ArcMap 应用程序的数据视图中导出类似,此脚本将导出单个数据框(而不是整个页面布局)。df_export_widthdf_export_height 的默认值分别是 640 和 480。通过传递这些参数的较大值,可以生成细节层次较高的输出图像。

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/15/2013