Resumen
The PDFFormat object represents a collection of Portable Document Format (PDF) file properties that can be configured and used with the export method on the Layout, MapFrame, and MapView objects to create an output PDF file.
Debate
PDF files are designed to be consistently viewable and printable across different platforms. They are commonly used for distributing documents on the web, and the format is now an official ISO standard for document interchange. PDFs are editable in many graphics applications. They can retain map georeference information, annotation, labeling, and feature attribute data in the file. Additionally, the entire document or individual layers can be rasterized to simplify the document and decrease file size.
The createExportFormat method can be used to create a PDFFormat object if the format parameter is set to PDF. The returned PDFFormat object contains all the properties associated with a generating a PDF file. These properties can be modified accordingly to produce different output results.
Propiedades
Propiedad | Explicación | Tipo de datos |
clipToElements (Lectura y escritura) | If set to True, include the areas of the page that have map or layout element content only, rather than exporting the entire page. This property only applies when exporting a Layout object. The default value is False. | Boolean |
compressVectorGraphics (Lectura y escritura) | Compress the vector content streams. This option should be kept True unless you need clear text for troubleshooting. The default value is True. | Boolean |
convertMarkers (Lectura y escritura) | Controls whether marker symbols based on font characters are exported as font characters or as polygons. Set this option to True to view the output on a machine that does not have the appropriate fonts installed when you cannot embed the fonts due to licensing or file format restrictions. This does not apply to text, only marker symbols based on fonts. The default value is False. | Boolean |
embedColorProfile (Lectura y escritura) |
Include the color profile set for the map or layout in the exported file. This helps create consistency in colors when the file is viewed on different devices. If the profile is not embedded, or a non-color-managed viewer is used, the colors may be significantly different than what is seen on-screen. The default value is True. Nota:This option is only available when color management is enabled. If color management is not enabled and the colorspace is set to CMYK, the CMYK colorspace is still included in the export. This may cause some colors to appear differently when viewing the exported file. | Boolean |
embedFonts (Lectura y escritura) | Include embeddable fonts in the exported file to maintain font consistency across different platforms. Fonts that do not support embedding are not included, regardless of this setting. The default value is True. Nota:To correctly edit text as graphics, Illustrator requires fonts to be installed and accessible. Check the sharing permissions before embedding and sharing fonts. | Boolean |
filePath (Lectura y escritura) | A string that represents the system path and file name, including the extension, for the exported file. | String |
georefInfo (Lectura y escritura) | Include geospatial information from the map or one or more map frames. If this information is included, you can extract x,y coordinate data and perform geographic measurements in supported PDF readers. The default value is True. | Boolean |
height (Lectura y escritura) | The height, in pixels, of the map area to be exported. This property only applies when exporting a MapView object. The default value is 960. | Double |
imageCompression (Lectura y escritura) | The compression scheme used to compress image or raster data in the output file. Choose from the following options below. The default value is ADAPTIVE.
| String |
imageCompressionQuality (Lectura y escritura) | The amount of image compression applied to the export. Low quality has a smaller file size but less clear data; max quality has a larger file size but crisper data. This only applies when certain compression types are used. The default value is 80. | Integer |
imageQuality (Lectura y escritura) | The amount of image resampling. The property determines the effective resolution of raster content on output. For instance, if imageQuality is set to BETTER, a resample ratio of 1:2, and the output resolution is set to 300 dpi, the raster content is output at approximately 150 dpi. In many cases, the raster data can be included at a lower dpi than the vector data without visibly affecting quality, reducing the output file size. The default value is BEST.
| String |
includeAccessibilityTags (Lectura y escritura) | If set to True, title, lanuguage, subject, author and keyword accessibility tags are written to the output file. The default value is True. | Boolean |
includeNonVisibleMapLayers (Lectura y escritura) | If set to True, this property ensures that all layers in the map are included in the exported file, including layers with visibility unchecked. The visibility status of all layers is retained in the exported file. Use this option to create deliverables with several views of the same data. When this property is set to False, only visible layers in the map are included in the exported file. Non-visible layers are dropped. The default value is False. | Boolean |
layersAndAttributes (Lectura y escritura) | Include layers in the map or layout that can be viewed and managed in supported PDF readers. Additionally, you can include the attribute data from the features. Including attributes for a large number of layers can affect performance and increase the size of the output. The default value is LAYERS_ONLY | String |
outputAsImage (Lectura y escritura) | Export vector content as an image. For maps or layouts containing vector layers with a high density of vertices, this can drastically reduce the output file size. The default value is False. Nota:Options specific to vector data, such as embedFonts, georefInfo and layersAttributes, are unavailable when outputAsImage is set to True. | Boolean |
removeLayoutBackground (Lectura y escritura) | Remove the page background as a graphic when exporting. This property only applies when exporting a Layout object. The default value is False. | Boolean |
resolution (Lectura y escritura) | The effective dpi of the output vector data. The default value is 96. Nota:When exporting a MapView, the dpi is calculated automatically using system dpi scaling and therefore this value will be ignored. | Integer |
showSelectionSymbology (Lectura y escritura) | Show selected features in the map or map frame as selected in the output file. Setting this value to False does not affect selection within the view, only in the output file. The default value is False. | Boolean |
simulateOverprint (Lectura y escritura) | Sometimes called soft proofing, simulate overprint shows a representation of how overlapping areas of ink will appear when printed on a page. You set up overprinting on the symbol layers of symbols or graphics. The default value is False. Nota:When you simulate overprint on export, vector features are rasterized into images. They are not maintained as individual vector layers in the output PDF document. This results in options specific to vector data, such as embedFonts, georefInfo, and layersAttributes, being unavailable. Learn more about overprinting. | Boolean |
width (Lectura y escritura) | The width, in pixels, of the map area to be exported. This property only applies when exporting a MapView object. The default value is 960. | Double |
Descripción general del método
Método | Explicación |
setImageCompression (image_compression) | A string constant that represents the compression scheme used to compress image or raster data in the output file. |
setImageQuality (image_quality) | A string constant that sets the amount of image resampling. |
setLayersAndAttributes (layers_attributes) | A string constant that specifies whether the PDF layer and PDF object data (attributes) will be included in the export file. |
Métodos
setImageCompression (image_compression)
Parámetro | Explicación | Tipo de datos |
image_compression | Below is a list of valid strings.
| String |
setImageQuality (image_quality)
Parámetro | Explicación | Tipo de datos |
image_quality | Below is a list of valid strings.
| String |
The value determines the effective resolution of raster content on output. For instance, if the output image quality ratio is set to 1:2, an image_quality value of BETTER, and the output resolution is set to 300 dpi, the raster content is output at approximately 150 dpi. In many cases, the raster data can be included at a lower dpi than the vector data without visibly affecting quality, reducing the output file size.
setLayersAndAttributes (layers_attributes)
Parámetro | Explicación | Tipo de datos |
layers_attributes | Below is a list of valid strings.
| String |
The output file size can get large depending on the number of features and density of vertices when using a value of LAYERs_ONLY and can get even larger if LAYERS_AND_ATTRIBUTES are exported.
Muestra de código
The following script exports a layout to PDF format using default property values.
p = arcpy.mp.ArcGISProject('current')
lyt = p.listLayouts()[0]
pdf = arcpy.mp.CreateExportFormat('PDF', r'C:\Temp\Output.pdf')
lyt.export(pdf)
The following script does the same export as the example above but then it configures the PDFFormat properties to create a PDF with a smaller file size. Before the script exports a second time, it modifies the original output filePath so you can compare the file sizes of the newly generated PDFs.
p = arcpy.mp.ArcGISProject('current')
lyt = p.listLayouts()[0]
pdf = arcpy.mp.CreateExportFormat('PDF', r'C:\Temp\PDF_output1.pdf')
lyt.export(pdf) #Export using default value
pdf.clipToElements = True #Default is False
pdf.embedColorProfile = False #Default is True
pdf.embedFonts = False #Default is True
pdf.georefInfo = False #Default is True
pdf.outputAsImage = True #Default is False
pdf.imageCompressionQuality = 10 #Default is 80
pdf.resolution = 50 #Default is 96
pdf.setImageQuality('FASTEST') #Default os BEST
pdf.setLayersAndAttributes('NONE') #Default is LAYERS_ONLY
pdf.filePath = r'C:\Temp\PDF_output2.pdf' #Override filePath from original
lyt.export(pdf) #Export to smaller PDF