I'm trying to export a single, multipage PDF using Data Driven Pages in ArcGIS 10.3. The background images for my maps are 15 large, high res overlapping rasters that are sometimes poor quality due to being underexposed or overexposed, but only in parts of each raster. I've dealt with this problem by going into layer properties, Symbology, and choosing a "Percent Clip" stretch and applying a gamma stretch from the current display extent. That way, my raster colors appear quite good on each page. When I click through the data driven pages manually, the rasters appear nicely rendered, with bright whites and dark blacks for each image.

However, when I export the map using data driven pages using the GUI (I'm a python coding noob), those preferences are not being respected in the final pdf document after exporting via data driven pages.

I thought the solution on the bottom of this page might work, because it forces each page to refresh before printing it to the final pdf, but my scripting knowledge leaves a lot to be desired and I'm having trouble applying the code to my own document.

It sounds like the solution might lie in using python scripting to force data driven pages to draw each page separately (using mxd.dataDrivenPages.refresh() ?), then append all the pages together in a final document.

I've messed around with script I found on these questions,

How to Prevent Data Driven Pages From Hanging on Subsequent Export?

but I just can't get it to work.

Has anyone has been able to get the stretched renderer to work in data driven pages?

  • @Nova Have you tested exporting one of your DDP pages to a different format (JPG, TIFF, etc.) ? How about using a different PDF print driver? If exporting to JPG works, you can use Python to export your DDP as an entire series of DDP pages as JPGs (or TIFFs or several other formats). IIRC in the GUI you can't export a DDP series as JPGs. – Dan C Jan 12 '18 at 15:26
  • Hi @DanC, I need them to be georeferenced. But good ideas there, I tried exporting them each as a separate page, and the symbology worked better, if not completely as expected... so I'm still looking for a solution. – Nova Jan 12 '18 at 16:34

This is the best I could come up with after some more searching and help from a past colleague.

It seems to apply the gamma stretch to MOST map pages, if not all. So if someone out there has another method I'd still be interested in learning it.

I'm new to python.

mxd = arcpy.mapping.MapDocument("CURRENT")

# Loop through each page in the data driven pages document
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
  mxd.dataDrivenPages.currentPageID = pageNum
  # Refresh the page every time so it re-draws
  # Export each page to an empty folder
  arcpy.mapping.ExportToPDF(mxd, r" Y:\MultiplePages\Mapbook_" + mxd.dataDrivenPages.pageRow.Record + ".PDF")
del mxd 

import os
# Change working directory
#make sure this lists your pdfs ONLY (they should be in their own folder)
# List all the pdfs in the folder
pdfList = os.listdir('.')
# Supply a filename for your final document
# Create the final document
pdfDoc = arcpy.mapping.PDFDocumentCreate(pdfpath)
# Append all the pages in your folder to the final document.
for aPdf in pdfList:

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.