I am trying to convert an MXD using a script from this link https://www.arcgis.com/home/item.html?id=4ddd1323ae0d4ebe8f8250992faab0f4

When I run the script I get the following error: Invalid MXD filename.

Looking at the command promt pasted below I can already see that there is path problems as the path I enter is different form the path I output (Missing '/'). However even if I create that bogus path and place the file there, there is still an error.

import arcpy, sys, os

arcpy.OverWriteOutput = 1

print "Enter folder path:"
mapDoc = raw_input()

print os.path.dirname(mapDoc) 
fullnam = os.path.basename(mapDoc)

nam = fullnam.strip(".mxd")
print nam

map = arcpy.mapping
mxd = map.MapDocument(mapDoc)

map_document = mxd 
out_pdf = os.path.dirname(mapDoc) + os.sep + nam + ".pdf"

data_frame = 'PAGE_LAYOUT'
resolution = "300"
image_quality = "NORMAL"
colorspace = "RGB"
compress_vectors = "True"
image_compression = "DEFLATE"
picture_symbol = 'RASTERIZE_BITMAP'
convert_markers = "False"
embed_fonts = "True"
layers_attributes = "NONE"
georef_info = "False"

map.ExportToPDF(map_document, out_pdf, data_frame, 640, 480, resolution, image_quality, colorspace, compress_vectors, image_compression, picture_symbol, convert_markers, embed_fonts, layers_attributes, georef_info)


Command Prompt

`(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>"C:\Us
ers\ant\Documents\MyCensus_Files\Python script\Export2PDF.py"
Enter folder path:
C:\Users\ant\Documents\MyCensus_Files\Python script
Python script
Traceback (most recent call last):
  File "C:\Users\ant\Documents\MyCensus_Files\Python script\Export2PDF.py
", line 22, in <module>
    mxd = map.MapDocument(mapDoc)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\arcobjects\mixins.
py", line 651, in __init__
    assert (os.path.isfile(mxd) or (mxd.lower() == "current")), gp.getIDMessage(
89004, "Invalid MXD filename")
AssertionError: Invalid MXD filename.

Looking for some assistance in fixing this path issue or even a script to convert batch mxd to pdf.

  • I see a lot of issues but first, are you typing “current” into the console/terminal? – PMK Apr 13 '19 at 2:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.