Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the PrintTask() function from the ArcGIS Online API. Works like a charm...untill you add your own graphics.

When I don't run the addedAskedSymbolsToMap function in the code below, and only have one feature layer, then the print is perfectly created. When I do run it, i'm adding custom symbols. The console shows the following error:

"Error performing execute operation"

What's the deal with custom graphics and PrintTask, how should I adjust the code below to something that's okay with the PrintTask function?

Here's the code:

dojo.require("dijit.dijit"); // optimize: load dijit layer

    var map;
    var testedArea = 'nederland';
    var basemapUrl = ""+testedArea+"_ondergrond/MapServer";
    var featureLayerUrl = ""+testedArea+"/FeatureServer/0";
    var printUrl = "";

    function init(){ = "/arcgisserver/apis/javascript/proxy/proxy.ashx";
        var initialExtent = new esri.geometry.Extent({"xmin":127181.62867976735,"ymin":6618002.046143801,"xmax":1141291.3011197727,"ymax":7298584.615330108,"spatialReference":{"wkid":102100}});
        map = new esri.Map("map", {
            extent: initialExtent,
            //zoom: 2
        dojo.connect(map, "onLoad", doQueries);
        //dojo.connect(map, "onLoad", createPrint);
        map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer(basemapUrl));

    function doQueries(){

        content = 'Cito100_onderdeel=1';
        queryContentSelect = new esri.tasks.Query();
        queryContentSelect.returnGeometry = true;
        queryContentSelect.outFields = ["Type", "NAME"];
        queryContentSelect.where = content;
        var featureLayer = new esri.layers.FeatureLayer(featureLayerUrl,{
            mode: esri.layers.FeatureLayer.MODE_SELECTION,
            outFields: ["*"]
        featureLayer.selectFeatures(queryContentSelect, esri.layers.FeatureLayer.SELECTION_NEW);

        //Set the content of the graphicsLayer selection
        var queryGraphicsTask = new esri.tasks.QueryTask(featureLayerUrl);
        var queryGraphicsSelect = new esri.tasks.Query();
        queryGraphicsSelect.returnGeometry = true;
        queryGraphicsSelect.outFields = ["Type", "NAME"];
        queryGraphicsSelect.objectIds = [1,12,14,15,24,25,89, 20];
        queryGraphicsTask.execute(queryGraphicsSelect, addAskedSymbolsToMap);

    function addAskedSymbolsToMap(featureSet){
        var graphicsLayer = new esri.layers.GraphicsLayer();

        //Add asked places to the graphics layer
        var i =1;
        dojo.forEach(featureSet.features, function(feature) {
            if(feature.attributes.Type == 'Gebied'){
                iconSymbolNumbered = new esri.symbol.PictureMarkerSymbol({
                    'yoffset': 0});
                iconSymbolNumbered = new esri.symbol.PictureMarkerSymbol({
                    'yoffset': 10});
            var graphic = new esri.Graphic(feature.toJson());

    function createPrint(){
        //Set up print stuff
        var printTask = new esri.tasks.PrintTask(printUrl);
        var params = new esri.tasks.PrintParameters();
        var template = new esri.tasks.PrintTemplate(); = map;
        template.exportOptions = {
            width: 595,
            height: 842,
            dpi: 96
        template.layout = "MAP_ONLY";
        template.preserveScale = false;

        params.template = template;

        //dojo.connect(map, "onLoad", function() {//Fire the print task
        //printTask.execute(params, printResult, printError);
        setTimeout(function(){printTask.execute(params, printResult, printError);},2500);

    function printResult(result){
    function printError(result){

share|improve this question
which version you are using for ArcGIS Server (10 or 10.1) and JSAPI (3.1or 3.3). I would recommend you to use sample reset services as mentioned in the examples and then try (some times print task does nor support 10.0 version) and please put your code in JSFiddle so it will easy to debug. thanks – Sunil Apr 22 '13 at 5:03
The server is om 10.11, i'm using API verse 3.4. So that shouldn't be the problem. I've browsed through the samples, like… but can't find the 'reset services' that you mentioned. What do you mean by that? A Fiddle isn't gonne work for the printtask, see – Dennis Hunink Apr 22 '13 at 8:23
sorry it was REST (not 'reset' spelling mistake) service..I will check JSFiddle and let you know ..thanks.. – Sunil Apr 22 '13 at 9:35
up vote 5 down vote accepted

As far as I know, there's two problems in this code. First one is, both Query and QueryTask doesn't define outputSpatialreference parameters. So this query returns there own spatialreference geometries instead of map's spatialreference.

queryContentSelect.outSpatialReference = map.spatialReference;

queryGraphicsSelect.outSpatialReference = map.spatialReference;

And second one is so strange. In this case, it's using jpeg file at PicureMarkerSymbol in some places. At this time, such a error was happened. So, I converted these symbols to png file, then error doesn't happened. unfortunately, I'm not sure why printTask won't works with jpeg. But I hope this workaround will helps you.

share|improve this answer
Thanks a Million! The trick was indeed in the combination of the spatialreference, the .png icons and additionally the moment the printTask is started. I had to set the first layer to MODE_SNAPSHOT and fire the PrintTask only onUpdateEnd(); But I wouldn't have figured that out without you're suggestions. Thanks so so much! – Dennis Hunink Apr 22 '13 at 8:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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