AnsweredAssumed Answered

print issue

Question asked by omar_cherdal on Jul 19, 2018

hey their i'm using arcgis api for js "3.25" i've struggeling with a print error and i don't know what to do

this is my printing code:

app.printUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";

esriConfig.defaults.io.proxyUrl = "/proxy/";
var permitUrl = "http://localhost:6080/arcgis/rest/services/Amendis/ArretAlsaOmar/MapServer/1";
var poolFeatureLayer = new FeatureLayer(permitUrl, {
    "mode": FeatureLayer.MODE_SNAPSHOT
});
map.addLayer(poolFeatureLayer);

// get print templates from the export web map task
var printInfo = esriRequest({
    "url": app.printUrl,
    "content": { "f": "json" }
});
printInfo.then(handlePrintInfo, handleError);

function handlePrintInfo(resp) {
    var layoutTemplate, templateNames, mapOnlyIndex, templates;

    layoutTemplate = arrayUtils.filter(resp.parameters, function(param, idx) {
        return param.name === "Layout_Template";
    });

    if ( layoutTemplate.length === 0 ) {
        console.log("print service parameters name for templates must be \"Layout_Template\"");
        return;
    }
    templateNames = layoutTemplate[0].choiceList;

    // remove the MAP_ONLY template then add it to the end of the list of templates
    mapOnlyIndex = arrayUtils.indexOf(templateNames, "MAP_ONLY");
    if ( mapOnlyIndex > -1 ) {
        var mapOnly = templateNames.splice(mapOnlyIndex, mapOnlyIndex + 1)[0];
        templateNames.push(mapOnly);
    }

    // create a print template for each choice
    templates = arrayUtils.map(templateNames, function(ch) {
        var plate = new PrintTemplate();
        plate.layout = plate.label = ch;
        plate.format = "PDF";
        plate.layoutOptions = {
            "authorText": "Made by:  Esri's JS API Team",
            "copyrightText": "<copyright info here>",
            "legendLayers": [],
            "titleText": "Alsa",
            "scalebarUnit": "Miles"
        };
        return plate;
    });

    // create the print dijit
    app.printer = new Print({
        "map": map,
        "templates": templates,
        url: app.printUrl
    }, dom.byId("print_button"));
    app.printer.startup();
}

function handleError(err) {
    console.log("Something broke: ", err);
}
and this is the error that gives me when i click on the button

Outcomes