Summary
The CreateExportFormat function creates an export format object and is used with the export method to generate the appropriate output export file.
Discussion
Once the export format object is generated, you may need to modify properties in order to properly format the desired output. To create the output export file, you need to pass the export format object into the format parameter on the export method which is available to multiple classes: BookmarkMapSeries, Layout, MapFrame, MapSeries, MapView, and Report.
Syntax
CreateExportFormat (format, {file_path})
Parameter | Explanation | Data Type |
format | The list of supported export formats is as follows:
| String |
file_path | The full system path, file name, and extension for the resulting export file. Note:This value does not need to be set initially but does need to be set before exporting to an output export file.(The default value is None) | String |
Code sample
The following script first exports a layout to PDF using all default values. It then configures the PDFFormat properties to create another 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