rking9

PrintTask with GraphicsLayer

Discussion created by rking9 on Dec 10, 2012
Latest reply on Jun 4, 2014 by ganeshssac
If I have any graphics in my graphics layer, my print task wont work. If I clear the graphics then it works.

 
   var date = new Date();
    var layoutOptions = { 
         titleText: "Map Title", 
         scalebarUnit: 'Miles', 
         authorText: "Author Name", 
         copyrightText: "2012 Copyright", 
         legendLayers: [] 
    };
    var layout = document.getElementById("PRINT_LAYOUT");
    var format = document.getElementById("PRINT_FORMAT");

    var printTemplate = new esri.tasks.PrintTemplate();
    printTemplate.format = format.options[format.selectedIndex].value;
    printTemplate.layout = layout.options[layout.selectedIndex].value;
    printTemplate.layoutOptions = layoutOptions;
    printTemplate.preserveScale = true;

    graphicsLayer.clear();
    var printParams = new esri.tasks.PrintParameters();
    printParams.map = map;
    printParams.outSpatialReference = map.spatialReference;
    printParams.template = printTemplate;

    var printUrl = "...myUrl...";
    var printTask = new esri.tasks.PrintTask(printUrl);

    printTask.execute(printParams, function (result) {
        PrintButton.src = oldSrc;
        window.open(result.url + "?timestamp=" + (new Date().getTime()));
    }, function (error) {
        PrintButton.src = oldSrc;
        var a = error;
        alert(a);
    });

Has anyone else ran into this problem?

I am using JavaScript API 3.1

Outcomes