I have an ArcGIS Javascript Map Application that uses the Print task to export the map to a PDF. I have given the users the ability to add graphics to the map, such as points or polygons, along with the ability to add a TextSymbol graphic in order to customize the PDF map output. The problem I am having is with the TextSymbol appearance on the PDF printout. For some reason I cannot change the color of the text on the output. Even if the text on the web map is red, the color of the text on the pdf is black. I have applied code to change the color of the textLayers by performing an esriRequest.setRequestPreCallback to intercept the JSON going to the Print service. However, the text still ends up black on the output. My code for that is below. I have done console.logs in order to see what the object looks like after changing the color and it does change it, but still the text ends up being black on the pdf output. Does anyone know how to either change the color of the text on the PDF output or know how to add some type of rectangle background on the TextSymbol so that the labels can be more visible on the PDF outputs?

function changeTextColor(){
    esriRequest.setRequestPreCallback(function(ioArgs) {
        if (ioArgs.content && ioArgs.content.Web_Map_as_JSON){
            var webMapAsJson = ioArgs.content.Web_Map_as_JSON;
            var webMapObj = JSON.parse(webMapAsJson);
            for (var w in webMapObj.operationalLayers){
                if (webMapObj.operationalLayers[w].id = "map_graphics" && webMapObj.operationalLayers[w].url == undefined){
                    for (var l in webMapObj.operationalLayers[w].featureCollection.layers){
                        if (webMapObj.operationalLayers[w].featureCollection.layers[l].layerDefinition.name == "textLayer"){
                            for (var f in webMapObj.operationalLayers[w].featureCollection.layers[l].featureSet.features){
                                //currently I am just trying to change the text to be turquoise but it keeps returning black text on pdf output
                                webMapObj.operationalLayers[w].featureCollection.layers[l].featureSet.features[f].symbol.color[0] = 0;
                                webMapObj.operationalLayers[w].featureCollection.layers[l].featureSet.features[f].symbol.color[1] = 255;
                                webMapObj.operationalLayers[w].featureCollection.layers[l].featureSet.features[f].symbol.color[2] = 255;
            ioArgs.content.Web_Map_as_JSON = JSON.stringify(webMapObj);
        return ioArgs;          
  • Maybe try the setColor method? symbol.setColor(new Color([0,255,255])); – Eok Sep 30 '15 at 16:49
  • Tried that but got this error: TypeError: webMapObj.operationalLayers[w].featureCollection.layers[l].featureSet.features[f].symbol.setColor is not a function – EvanL Sep 30 '15 at 18:39
  • I have also tried copying and pasting the JSON text (with the altered color) into the execute task of the actual print service, and that still returns black text. (I tried changing the size of the font as well and that also did not do anything) – EvanL Sep 30 '15 at 18:41
  • Can you specify the version number of the JS API you're using? Just in case it's a version specific issue. – Eok Oct 1 '15 at 22:38
  • I am using arcgis js api version 3.14 – EvanL Oct 5 '15 at 16:50

I solved my issue using the answer to this thread - https://geonet.esri.com/thread/118646. I ended up not needing to make a esriRequest.setRequestPreCallback afterall. I created a simple option drop down menu for color and size that the user can select and then draw a textSymbol using those options and it ends up coming out correctly on the PDF output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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