I wrote a script that exports a title page and a map series. When I run the script manually in PyCharm, the title page exports correctly.
When I set up the script to run in windows task scheduler, the title page exports without the map frame (see image below)
Has anyone come across this and is there a way to fix it?
Here's the code that exports the title page and map series.
proProject = "\\\\Scripts\\Python\\MapBook\\MapBook.aprx"
PDFDir = "\\\\Scripts\\Python\\MapBook\\Output"
p = arcpy.mp.ArcGISProject(proProject)
try:
# Export new title page to pdf
TitleFile = PDFDir + "\\TitlePage.pdf"
tLayout = p.listLayouts("TitlePage")[0]
tLayout.exportToPDF(TitleFile)
print("Exported new title page " + "\n" + arcpy.GetMessages())
mylog.write("Exported new title page" +"\n")
except:
message = arcpy.GetMessages()
print(message)
mylog.write("Error exporting new title page" + message + "\n")
arcpy.AddMessage(message)
mylog.write("Processing Aborted...." + "\n")
sys.exit("Processing Aborted..")
try:
# Export new map book pages to pdf
MBfile = PDFDir + "\\MapPages.pdf"
mbLayout = p.listLayouts("MapPages")[0]
mapSeries = mbLayout.mapSeries
if mapSeries.enabled:
mapSeries = mbLayout.mapSeries
mapSeries.refresh()
mapSeries.exportToPDF(MBfile)
print("Exported new map pages" + "\n" + arcpy.GetMessages())
mylog.write("Exported new new map pages" +"\n")
except:
message = arcpy.GetMessages()
print(message)
mylog.write("Error exporting new map pages" + message + "\n")
arcpy.AddMessage(message)
mylog.write("Processing Aborted...." + "\n")
sys.exit("Processing Aborted..")