How to use Python to export selected data driven pages?

488
3
Jump to solution
01-26-2012 05:21 AM
Ulises
by
Occasional Contributor III
I???m trying to export to pdf just the selected data driven pages from a test mxd prepared, but I keep getting an error message.  I???m writing in the python window in desktop the following lines:

mxd = arcpy.mapping.MapDocument ("C:/Workspace/MyTESTS/DDP/MyDDP1K_Test.mxd")  tempDDP = mxd.dataDrivenPages  tempDDP.exportToPDF("C:/Workspace/MyTESTS/DDP/tempDDP.pdf","CURRENT") ??? test1...works fine  tempDDP.exportToPDF("C:/Workspace/MyTESTS/DDP/tempDDP.pdf","RANGE","5-12") ??? test2...works fine  tempDDP.exportToPDF("C:/Workspace/MyTESTS/DDP/tempDDP.pdf","SELECTED")  --test3...error (I had 3 pages selected and it works fine when doing it manually) 


Any help is appreciated...
Ulises Feliciano Troche
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JeffBarrette
Esri Regular Contributor
It is because you are assigning "PDF_MULTIPLE_FILES_PAGE_INDEX" to the wrong parameter.  You are assigning it to {page_range_string} and not {multiple_files}.

To skip {page_range_string} and assing {multiple_files} try:

tempDDP.exportToPDF(temp_filename, "SELECTED",multiple_files="PDF_MULTIPLE_FILES_PAGE_INDEX")


If you want to skip parameters in Python you must type in the parameter name.

Jeff

View solution in original post

0 Kudos
3 Replies
Ulises
by
Occasional Contributor III
Don't know why, but suddenly I'm able to export the selected pages, as expected, without any changes to the code.  The issue now is that I want to export each page to separate pdf files, but can�??t.  I change the code to something like�?�

tempDDP.exportToPDF(temp_filename, "SELECTED","PDF_MULTIPLE_FILES_PAGE_INDEX")


it runs ok, but still creates just 1 pdf file with all my selected pages in it.

any help is appreciated...
Ulises Feliciano Troche
0 Kudos
JeffBarrette
Esri Regular Contributor
It is because you are assigning "PDF_MULTIPLE_FILES_PAGE_INDEX" to the wrong parameter.  You are assigning it to {page_range_string} and not {multiple_files}.

To skip {page_range_string} and assing {multiple_files} try:

tempDDP.exportToPDF(temp_filename, "SELECTED",multiple_files="PDF_MULTIPLE_FILES_PAGE_INDEX")


If you want to skip parameters in Python you must type in the parameter name.

Jeff
0 Kudos
Ulises
by
Occasional Contributor III
Thanks, Jeff...

Problem solved...
Ulises Feliciano Troche
0 Kudos