Further enhancement

It is possible to generalise the script to report different SWD files. This is done by making minor changes to the Python script and Task Scheduler configuration

Using the Python standard library function "sys.argv" we can provide our script with the SWD filename and PDF export folder. The example script will use this to export different maps to different users.

"sys.argv" imports command line arguments passed to the script at run-time, which are specified by a Task Scheduler "Action".

In Python, "sys.argv" is a list. The first item in the list is always the script name so extra variables passed to the script can be accessed as 'argv[1]', 'argv[2]' and so on.

Modifying the script to replace the SWD filename and PDF output directory variables with the "sys.argv" variables becomes:

import sis
from time import strftime,gmtime
import os.path
from sys import argv
# Configuration variables:
# Check if all commandline arguments exist
if len(argv) == 3:
reportSwdFileName = argv[1]
pdfOutputDirectory = argv[2]
        # Define default values if no command line arguments are passed
reportSwdFileName = "C:\\data\\MyMap.swd"
pdfOutputDirectory = "C:\\Reports"
# Get SWD Name
swdName = os.path.splitext(os.path.basename(reportSwdFileName))[0]
# Create timestamp using standard library (non-SIS)
time = strftime("%d-%m-%Y @Time-%H-%M-%S", gmtime())
# ExportPdf parameters
pdfName = "\\" + swdName + "-" + time + ".pdf"
pdfFilename = pdfOutputDirectory + pdfName
paperFormat = "A4*"
parameters = ""
if __name__ == "__main__":
s = sis.GisLink()
s.ExportPdf(pdfFilename, paperFormat, parameters)

The order of the additional arguments is now fixed. The SWD file location should be passed first and the report output folder second.