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, and MapView 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

PropertyExplanationData Type
clipToElements
(Read and Write)

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
(Read and Write)

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
(Read and Write)

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
(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 True.

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 True.

Note:

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
(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 True.

Boolean
height
(Read and Write)

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
(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 ADAPTIVE.

  • ADAPTIVE JPEG and Deflate compression are combined, depending on the contents of the stream. This works well for most cases.
  • DEFLATE Lossless compression method that works well for most cases.
  • JPEG Lossy compression method that works well for photographic-type images.
  • JPEG2000Higher quality compression with file sizes smaller than JPEG. This compression is lossless if jpeg_compression_quality is set to 100.
  • LZW Lossless compression method using a code table.
  • NONECompression is not applied.
  • RLE Run-length encoded compression, a lossless compression method that works well if there are large areas of the same color.
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 80.

Integer
imageQuality
(Read and Write)

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.

  • 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
String
includeAccessibilityTags
(Read and Write)

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
(Read and Write)

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
(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 LAYERS_ONLY

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 False.

Note:

Options specific to vector data, such as embedFonts, georefInfo and layersAttributes, are unavailable when outputAsImage is set to True.

Boolean
removeLayoutBackground
(Read and Write)

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
(Read and Write)

The effective dpi of the output vector data. The default value is 96.

Note:

When exporting a MapView, the dpi is calculated automatically using system dpi scaling and therefore this value will be ignored.

Integer
showSelectionSymbology
(Read and Write)

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
(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. The default value is False.

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 embedFonts, georefInfo, and layersAttributes, being unavailable. Learn more about overprinting.

Boolean
width
(Read and Write)

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

Method Overview

MethodExplanation
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.

Methods

setImageCompression (image_compression)
ParameterExplanationData Type
image_compression

Below is a list of valid strings.

  • ADAPTIVE JPEG and Deflate compression are combined, depending on the contents of the stream. This works well for most cases.
  • DEFLATE Lossless compression method that works well for most cases.
  • JPEG Lossy compression method that works well for photographic-type images.
  • JPEG2000 Higher-quality compression with file sizes smaller than JPEG . This compression is lossless if imageQuality is set to 100.
  • LZWLempel-Ziv-Welch, a lossless compression method using a code table.
  • NONECompression is not applied.
  • RLE Run-length encoded compression, a lossless compression method that works well if there are large areas of the same color.
String
setImageQuality (image_quality)
ParameterExplanationData Type
image_quality

Below is a list of valid strings.

  • 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
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)
ParameterExplanationData Type
layers_attributes

Below is a list of valid strings.

  • LAYERS_AND_ATTRIBUTES Export PDF layers only
  • LAYERS_ONLY Export PDF layers and feature attributes
  • NONEDo not export any PDF information
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.

Code sample

PDFFormat example 1

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)
PDFFormat example 2

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