I am trying to create an atlas with embedded title page and extra reports pages. Seems that I need to use Python scripts for this. I am not programmer and never worked with python. I found necessary script but then faced with a problem to make an export of pages from mxd
Please see my script:
import arcpy, os
# Create an output location variable
outDir = "K:/IM/02_GIS/01_Projects/Final"
# Create a new, empty pdf document in the specified output location folder
finalpdf_filename = outDir + "/Test_Atlas_Final.pdf"
if os.path.exists(finalpdf_filename):
os.remove(finalpdf_filename)
finalPdf = arcpy.mapping.PDFDocumentCreate(finalpdf_filename)
# Add the title page to the pdf
finalPdf.appendPages("K:/IM/02_GIS/01_Projects/TitlePage.pdf")
# Add the overview map to the pdf
finalPdf.appendPages("K:/IM/02_GIS/01_Projects/IndexMap.pdf")
# Export the Data Driven Pages to a temporary pdf and then add it to the
# final pdf. Alternately, if your Data Driven Pages have already been
# exported, simply append that document to the final pdf.
#
mxdPath = "K:/IM/02_GIS/01_Projects/AOR_General_v2_Atlas_Test1_1.mxd"
tempMap = arcpy.mapping.MapDocument(mxdPath)
tempDDP = tempMap.dataDrivenPages
temp_filename = "K:/IM/02_GIS/01_Projects/tempDDP.pdf"
if os.path.exists(temp_filename):
os.remove(temp_filename)
tempDDP.exportToPDF(temp_filename, "ALL")
finalPdf.appendPages(temp_filename)
# Insert the pdf pages containing the reports and graphs into the final pdf
#
finalPdf.insertPages("K:/IM/02_GIS/01_Projects/Report_pg4.pdf", 4)
# Update the properties of the final pdf
finalPdf.updateDocProperties(pdf_open_view="USE_THUMBS",
pdf_layout="SINGLE_PAGE")
# Save your result
finalPdf.saveAndClose()
# Delete variables
del finalPdf
Error I keep getting
Runtime error
Traceback (most recent call last):
File "<string>", line 28, in <module>
File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\utils.py", line 182, in fn_
return fn(*args, **kw)
File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\utils.py", line 182, in fn_
return fn(*args, **kw)
File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\_mapping.py", line 447, in exportToPDF
return convertArcObjectToPythonObject(self._arc_object.exportToPDF(*gp_fixargs((out_pdf, page_range_type, page_range_string, multiple_files, resolution, image_quality, colorspace, compress_vectors, image_compression, picture_symbol, convert_markers, embed_fonts, layers_attributes, georef_info, jpeg_compression_quality, show_selection_symbology), True)))
AttributeError: PageLayoutObject: Error in exporting pages
It works well till this step # Add the overview map to the pdf
It adding overview map perfectly and error occurs during proceeding of the next step.
mxdPath
tofinalPdf.appendPages(temp_filename)
)