I ended up solving this by making my own customized html page within the onDirectionsFinished function of widget.js of Directions widget. the printresult function is where you can populate a global variable to store the map jpg url
//added code............................................................................................
const div = document.createElement('div');
const img = document.createElement('img');
const mapImg = document.createElement('img');
//Had to set a timeout to allow the printtask results time to catch up
const myTimeout = setTimeout(finishhim, 7000);
//Use printtask to get image
var url = 'https://arcgis.com/mapping4/rest/services/Custom_Print_Service/GPServer/Export%20Web%20Map';
var oWid = map.width/2;
var oHgt = map.height/2;
var printTask = new PrintTask(url);
var template = new PrintTemplate();
var br = document.createElement("br");
template.format = "jpg";
template.layout = "MAP_ONLY";
template.preserveScale = true;
template.showAttribution = false;
img.src='https://localhost:3344/webappbuilder/apps/7/widgets/Directions/images/coplogo.png';
var params = new PrintParameters();
params.map = this.map;
params.template = template;
printTask.execute(params, lang.hitch(this, this.printResult));
function finishhim(){
const mapImg2 = document.createElement('img');
div.appendChild(img);
div.appendChild(br);
const p = document.createElement('p');
var x = [];
x.push('<br/>');
div.innerHTML += x;
if (evt.result.routeResults.length > 0) {
const features = evt.result.routeResults[0].directions.features;
count = 0;
features.forEach(function (result, i) {
if (count > 0) {
x.push(result.attributes.text);
div.innerHTML += count + '--' + x[count] + '<br>';
}
count = count + 1;
});
}
mapImg2.src=img2txt;
div.appendChild(mapImg2);
const htmlString = div.outerHTML;
const newWindow = window.open();
newWindow.document.write(htmlString);
}
//............................................................................................................
if(lang.isArrayLike(routeResults) && routeResults.length > 0){