Print is not working in WebAppBuilder

3734
16
03-29-2018 05:51 AM
mohannainar1
Emerging Contributor

1. It says "No Access-Control-Allow-Orgin" , my mapservice is not secured . I am using the web adaptor URL for print task . 

2. ArcGIS Server and application both are running same machine. 

3. I tried including this is code (esriConfig.request.corsEnabledServers.push("https://myserver");) in startup function of the widget , same error message I am getting. 

Below is code am using for printing 

_onBtnPrintClicked: function(){
var legendLayer = new LegendLayer();
legendLayer.layerId = "WidgetName";
legendLayer.subLayerIds = [0];
legendLayer.subLayerIds = [1];
var url = "https://servername/arcgis/rest/services/ExportWebMap5/GPServer/Export%20Web%20Map";
var printTask = new PrintTask(url);
var params = new PrintParameters();
var template = new PrintTemplate();
template.format = "PDF";
template.layout = "Layout";
template.layoutOptions = {//"legendLayers": [legendLayer], // empty array means no legend
"titleText": "Map Print",
"authorText": "xxxxxx",
"copyrightText": "yyyyy",
"scalebarUnit": "Kilometers",
"customTextElements": [{"titleID": "Map Reports"}, {"genderID": "All"}]
};
template.preserveScale = false;
debugger;
template.exportOptions = {
width:500,
height:600,
dpi:96
};
params.map = this.map;
params.template = template;
printTask.on("error",lang.hitch(this, this._printResultError));
printTask.execute(params, lang.hitch(this, this._printResult));
},

0 Kudos
16 Replies
RobertScheitlin__GISP
MVP Emeritus

Mohan,

   If your map services and print service are using the web adaptor then there would not be the :3344 in the URL. You error like a url with :3344 in the url, so some url in your app is not using the web adaptor url and thus the app see that url as coming from a different machine.

mohannainar1
Emerging Contributor

I am running the application from web app builder that is the reason it is using 3344 , I will host the application in IIS and will let you know the output. 

0 Kudos
mohannainar1
Emerging Contributor

Now I have hosted the application in IIS, getting different error now.  For smaller area( number of polygon geometry may be 5 or 10) the print works fine . For larger area (more number of polygon geometry) print is not working . 

Proxy used in config.json file is 

Getting an error like this 

For smaller area the code works fine , for larger area the issue is there . 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mohan,

   I almost never use localhost. And you should not be using it in this situation

0 Kudos
mohannainar1
Emerging Contributor

Same error I am getting, if i use server name also.

0 Kudos
mohannainar1
Emerging Contributor

Robert,

So far I am using map service as BaseMap and I am able see the print  output for smaller area .  If I use the actual basemap (which I created ) , the print output is coming as blank. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mohan,

   I am not sure why you are having such a hard time with this. So do you get any proxy errors in the console now?

You have your config.json set to always use proxy, that is not a good setting as everything does not need the extra step of going through the proxy (change to "alwaysUseProxy": false,). Is you app public yet, were I can test?

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

mohan nainar  I'm having a similar issue with my basemap not showing up in my printout, but the rest of my layers do appear. Mine is not in WAB in this case, but is a JS web page. Just in case it is related or if there are common items, may be we can see a pattern Print GP service not printing cached basemap (AGS 10.5.1) 

BTW  rscheitlin , I did try the "alwaysUseProxy":false as you recommended, but no change, and the proxy is working for display of all tiled and dynamic the services.  The print GP tool is not throwing any errors and seems to be working for all except the tiled basemap. 

I have tested some addition things and will include them on my thread I link to above.  In my case, I think this is a bug with the basemap tiled service in 10.5.1 ....maybe it doesn't like the v2 compact format of 10.5.1?  The 10.2.2 basemap uses the v1 compact version.

0 Kudos
mohannainar1
Emerging Contributor

I changed to alwaysUseProxy as false , even though I am getting empty base map in print. No proxy errors in console.Due to some restriction I can not publish the app in public. 

0 Kudos