Is there a way to customize ArcGIS print service so that it will not print the layer id and the string that is given in ClassBreakRenderer in the legend.

var layer = new FeatuerLayer(url, {
  id: "featureLayerId",
  opacity: 0.5

var renderer = new ClassBreakRenderer(null, "columnName");

var legendLayer = new LegendLayer();
lengendLayer.layerId = "featureLayerId";

1 Answer 1


Intercept the Print request by using the esri/request setRequestPreCallback method. Parse the WebMap String to convert it to JSON. Change your layer id's and stringify back.

esriRequest.setRequestPreCallback(function(ioArgs) {

         if (ioArgs.content && ioArgs.content.Web_Map_as_JSON){ //Intercept Print Call

              var webMapAsJson = ioArgs.content.Web_Map_as_JSON;
              var webMapObj = JSON.parse(webMapAsJson);

              // This is where you do you magic.
              // Loop through webMapObj.operationalLayers.
              // It has the layer id that you want to change

              ioArgs.content.Web_Map_as_JSON = JSON.stringify(webMapObj);

      return ioArgs;          
  • Sorry to reply so late as I was working on other things. Anyway, thank you for your help, you saved my day.
    – Ikki Cheng
    Commented Jan 18, 2015 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.