AnsweredAssumed Answered

API 4.5 Print Service Not Honoring Visibility in SubLayers

Question asked by david.plume on Oct 3, 2017

I am using the ArcGIS Javascript 4.5 API.  I'm have a view and map framework setup using a MapImage service.  I am able to manage my sublayers visibility using code that looks like this:


setSubLayerVisibility: function(id, sMapLayName) {


var lay = this.eMap.findLayerById(sMapLayName);

var sublay = lay.findSublayerById(parseInt(id));
sublay.visible = !sublay.visible;

catch (ex) {

var sMsg = "esriPanel.esriMap2.setSubLayerVisibility: " + ex.message;

}, // eo setSubLayerVisibility


I've checked in the subLayers before and after the visible toggle and verified that the layer visibility is changed.  The visibility also toggles fine in my map view.  


However, when I send this to my printing service the the layer visibility does not match the new configuration -- the visibility appears to be as it was when the map/view was created.  However, I've also checked the visibility in the sublayers.items of the MapImage layer and see that the visibility is as expected.


Here is my code that I'm using to send the view to the print task:


require (["esri/tasks/PrintTask", "esri/tasks/support/PrintTemplate", "esri/tasks/support/PrintParameters"], function(prnTask, prnTemplate, prnParams){


pTemplate = new prnTemplate({

format: 'pdf',
exportOptions: {dpi: 300},
layout: mapSize,
preserveScale: false,
layoutOptions: {
titleText: mapTitle,
authorText: mapAuthor,
scalebarUnit: 'Miles'


pParams = new prnParams({
view: win.eMap.eView, // my win.viewModel has a reference to my map object. eView is a reference to my esri view in my map object.
template: pTemplate


var pTask = new prnTask({
url: printService




resLab.update("<a href=\"" + result.url + "\" target=\"_blank\">Download PDF File</a>");
msgTextArea.setValue("Printing complete. Click on blue link above to download");



msgTextArea.setValue("Error: " + error.details.messages);

sMsg = "winMakeMapPdfViewController.onButtonClick(): " + error.details.messages;


); // eo execute

}); // eo esri Print task


Ideas, suggestions would be very welcome -- Thanks!

#MapImage, Visibility, PrintService