In a separate post a while back, I was hoping to solicit some guidance on how to use the geoprocessing widget. After some distractions, I'm now returning to this effort.
I have built a few functioning Python tool(boxe)s with ArcGIS Pro now. I understand how to interact with the map layout in Pro to programmatically create PDF of my map and modify the map for conversion to PDF. I am not completely sure how that related to what ESRI calls a "staged layout template." But that has to be similar to what I'm doing. First, I want to replace my aprx reference to a project file with one to a web map.
For advanced printing scenarios, you ... can use the ConvertWebMapToMapDocument (for ArcMap) or ConvertWebMapToArcGISProject (for ArcGIS Pro) functions in the Python arcpy module.
So I am trying to leverage
arcpy.mp.ConvertWebMapToArcGISProject(<webmap_as_json>, <some_wonderful_pdf>)
There is no simple way of generating some sample JSON describing your web map that you could use to test your script. So after publishing a script as a geoprocessing service that takes <webmap_as_json> as an argument, how do I pass the json ?
I can hook Web AppBuilder's Geoprocessing widget into my geoprocessing services but it's needing that JSON to feed on.
So I'm inclined to think I'm headed down the wrong path.
Solved! Go to Solution.
Doing a post-mortem on this before I forget....So I dropped my efforts to use the OTB GP widget, instead, I created a GP tool in ArcGIS Pro (using Python) and
ConvertWebMapToArcGISProject
which allows you to create an in-memory APRX and then massage it to your heart's delight - iterate over maps or layers, choose a pre-configured template, and export that to PDF.
To consume that, I created a custom widget and in it, I did something like this:
printFromJSON : function (){
var currentMap = this.map;
var printTask = new PrintTask();
var params = new PrintParameters();
params.map = currentMap;
var webMapAsJSON = printTask._getPrintDefinition(currentMap, params);
var webMapAsJSONasString = JSON.stringify(webMapAsJSON);
var file;
var gpParams = {"Web_Map_as_JSON" : webMapAsJSONasString,
"PDFOutputFile" : file};
gp.submitJob(gpParams, this.completeCallback, this.statusCallback);
},
//Note the "var file" in there. It has to match any output parameters you've configured in your GP tool.
Doing a post-mortem on this before I forget....So I dropped my efforts to use the OTB GP widget, instead, I created a GP tool in ArcGIS Pro (using Python) and
ConvertWebMapToArcGISProject
which allows you to create an in-memory APRX and then massage it to your heart's delight - iterate over maps or layers, choose a pre-configured template, and export that to PDF.
To consume that, I created a custom widget and in it, I did something like this:
printFromJSON : function (){
var currentMap = this.map;
var printTask = new PrintTask();
var params = new PrintParameters();
params.map = currentMap;
var webMapAsJSON = printTask._getPrintDefinition(currentMap, params);
var webMapAsJSONasString = JSON.stringify(webMapAsJSON);
var file;
var gpParams = {"Web_Map_as_JSON" : webMapAsJSONasString,
"PDFOutputFile" : file};
gp.submitJob(gpParams, this.completeCallback, this.statusCallback);
},
//Note the "var file" in there. It has to match any output parameters you've configured in your GP tool.