I have a python script that querying some values and appending them to Layout. I'm applying symbology, labeling, and definition query. the script running well, but when exporting to PDF the symbology and labeling don't appears.
Although when I zoom in or out from the layout all appears.
the first image from the map (with labeling &symbology)
the second image from the layout (without labeling &symbology)
Are you saving the map after the updates, symbology, etc. but before the PDF export?
R_
Maybe add,
time.sleep(4) ensures that all changes have time to be fully applied before exporting to PDF.
import arcpy
import time
# Define your project and layout
aprx = arcpy.mp.ArcGISProject("CURRENT")
layout = aprx.listLayouts()[0]
# Define your map frame and map
map_frame = layout.listElements("MAPFRAME_ELEMENT")[0]
map_view = map_frame.map
layer = map_view.listLayers()[0] # Modify as per your layer
# Refresh the map view
map_frame.camera.setExtent(map_frame.camera.getExtent()) # Trigger a refresh by resetting the extent
# Wait for a moment to ensure all changes are applied
time.sleep(4)
# Export to PDF
output_pdf = r"path_to_your_output.pdf"
layout.exportToPDF(output_pdf)
Yes, I did but not working.
Maybe increase the sleep time.
the issue still occurred.
Maybe convert labels to annotation using, arcpy.cartography.ConvertLabelsToAnnotation, before the export.