PDFFormat
Summary
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, MapView, MapSeries, BookmarkMapSeries and Report objects to create an output PDF file.
Discussion
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.
Properties
| Name | Explanation | Data type |
|---|---|---|
|
author (Read and Write) |
A string that represents the author of the document. |
String |
|
clipToElements (Read and Write) |
If set to |
Boolean |
|
compressVectorGraphics (Read and Write) |
Compress the vector content streams. This option should be kept |
Boolean |
|
convertMarkers (Read and Write) |
Controls whether marker symbols based on font characters are exported as font characters or as polygons. Set this option to |
Boolean |
|
embedColorProfile (Read and Write) |
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 Note: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 (Read and Write) |
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 Note:To correctly edit text as graphics, Illustrator requires fonts to be installed and accessible. Check the sharing permissions before embedding and sharing fonts. For high-range characters or ligatures, font embedding should be used to ensure proper addressing of these high-range characters. In the case where a font with high-range characters or ligatures cannot be embedded, check the Draw glyphs as geometry property on the text symbol. |
Boolean |
|
filePath (Read and Write) |
A string that represents the system path and file name, including the extension, for the exported file. |
String |
|
georefInfo (Read and Write) |
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 |
Boolean |
|
height (Read and Write) |
The height, in pixels, of the map area to be exported. This property only applies when exporting a |
Double |
|
imageCompression (Read and Write) |
The compression scheme used to compress image or raster data in the output file. Choose from the following options below. The default value is
|
String |
|
imageCompressionQuality (Read and Write) |
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 |
Integer |
|
imageQuality (Read and Write) |
The amount of image resampling. The property determines the effective resolution of raster content on output. For instance, if
|
String |
|
includeAccessibilityTags (Read and Write) |
Output a tagged PDF file where text can be read by screen readers or other assistive technology. A tagged PDF file can include alt text—a text description of a graphic element that a screen reader uses to describe the element—for map frames, pictures, and chart frames. Alt text is added in the Element Pane for each element. The default value is |
Boolean |
|
includeNonVisibleMapLayers (Read and Write) |
If set to |
Boolean |
|
keywords (Read and Write) |
A string that represents keywords that can assist in document searches. |
String |
|
languageCode (Read and Write) |
A string that represents a standardized country code abbreviation (ISO3166) and a language code abbreviation (ISO639). For example, |
String |
|
layersAndAttributes (Read and Write) |
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
Note:Feature attributes will not be available if |
String |
|
outputAsImage (Read and Write) |
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 Note:Options specific to vector data, such as |
Boolean |
|
rasterAsSingleTile (Read and Write) |
If set to Note:If sufficient memory cannot be allocated, the export process will fail. To reduce memory requirements, set |
Boolean |
|
removeLayoutBackground (Read and Write) |
Remove the page background as a graphic when exporting. This property only applies when exporting a |
Boolean |
|
resolution (Read and Write) |
The effective dpi of the output vector data. The default value is 96. Note:When exporting a |
Integer |
|
showSelectionSymbology (Read and Write) |
Show selected features in the map or map frame as selected in the output file. Setting this value to |
Boolean |
|
simulateOverprint (Read and Write) |
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. It is only applies if the color model is set to CMYK. The default value is Note: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 |
Boolean |
|
subject (Read and Write) |
A string that represents a brief overview of what the document is about. |
String |
|
title (Read and Write) |
A string that represents the document title. This will be displayed when the document is opened. |
String |
|
width (Read and Write) |
The width, in pixels, of the map area to be exported. This property only applies when exporting a |
Double |
Methods
setImageCompression(image_compression)
A string constant that represents the compression scheme used to compress image or raster data in the output file.
| Name | Explanation | Data type |
|---|---|---|
|
image_compression |
Below is a list of valid strings.
|
String |
setImageQuality(image_quality)
A string constant that sets the amount of image resampling.
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.
| Name | Explanation | Data type |
|---|---|---|
|
image_quality |
Below is a list of valid strings.
|
String |
setLayersAndAttributes(layers_attributes)
A string constant that specifies whether the PDF layer and PDF object data (attributes) will be included in the export file.
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.
Note:
Feature attributes will not be available if includeAccessibilityTags is set to True.
| Name | Explanation | Data type |
|---|---|---|
|
layers_attributes |
Below is a list of valid strings.
|
String |
Code sample
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