AnsweredAssumed Answered

Poor Legend Symbol Quality when using PrintTask in API 3.x

Question asked by lorieme on Mar 15, 2018
Latest reply on Mar 16, 2018 by lorieme

When using the PrintTask and PrintTemplate in the ArcGIS API for JavaScript 3.16, we are getting poor symbol quality in the Legend when using format = PDF.  The best quality occurs in Template LetterPortraitPDF, but LetterLandscapePDF, TabloidPortaitPDF, and TabloidLandscapePDF have poor quality legend symbols.  See Legends below (in order listed:  Letter Portrait PDF, Letter Landscape PDF, Tabloid Portrait PDF, and Tabloid Landscape PDF).

 

Question:  How can I control for the legend symbol quality using the PrintTask?

 

Portait PDF -- decent Legend

Letter Landscape PDF -- Poor Legend

Tabloid Portrait PDF -- Poor Legend

Tabloid Landscape PDF -- Poor Legend

 

Here are the templates in our dropdown list:

 

<select id="dlPrintTemplates" style="width:100%;">

<option value="Letter ANSI A Landscape">Letter Landscape(PDF)</option>

<option value="Letter ANSI A Portrait">Letter Portrait(PDF)</option>

<option value="MAP_ONLY">Map Only Landscape(PNG)</option>

<option value="Tabloid ANSI B Landscape">Tabloid Landscape(PDF)</option>

<option value="Tabloid ANSI B Portrait">Tabloid Portrait(PDF)</option>

</select>

 

Here is the code that sets up the PrintTask and PrintTemplate (Note:  multiple legendlayers because using multiple map services)

 

var printUrl = "http://gisfarm.spokanecounty.org/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";

var printTask = new PrintTask(printUrl);

var template = new PrintTemplate();

template.format = "PDF";

template.layout = $('#dlPrintTemplates').val();

var tempLegendArray = [];

if (legendLayer1.subLayerIds.length > 0 && legendLayer2.subLayerIds.length > 0 && legendLayer3.subLayerIds.length > 0) {

template.layoutOptions = {

legendLayers: [legendLayer1, legendLayer2, legendLayer3],

titleText: customHeader,

scalebarUnit: "Feet"

};

}

else {

if (legendLayer1.subLayerIds.length > 0 && legendLayer2.subLayerIds.length > 0 && legendLayer3.subLayerIds.length == 0) {

template.layoutOptions = {

legendLayers: [legendLayer1, legendLayer2],

titleText: customHeader,

scalebarUnit: "Feet"

};

}

else {

if (legendLayer1.subLayerIds.length == 0 && legendLayer2.subLayerIds.length > 0 && legendLayer3.subLayerIds.length > 0) {

template.layoutOptions = {

legendLayers: [legendLayer2, legendLayer3],

titleText: customHeader,

scalebarUnit: "Feet"

};

}

else {

if (legendLayer1.subLayerIds.length > 0 && legendLayer2.subLayerIds.length == 0 && legendLayer3.subLayerIds.length > 0) {

template.layoutOptions = {

legendLayers: [legendLayer1, legendLayer3],

titleText: customHeader,

scalebarUnit: "Feet"

};

}

else {

if (legendLayer1.subLayerIds.length > 0 && legendLayer2.subLayerIds.length == 0 && legendLayer3.subLayerIds.length == 0) {

template.layoutOptions = {

legendLayers: [legendLayer1],

titleText: customHeader,

scalebarUnit: "Feet"

};

}

else {

if (legendLayer1.subLayerIds.length == 0 && legendLayer2.subLayerIds.length > 0 && legendLayer3.subLayerIds.length == 0) {

template.layoutOptions = {

legendLayers: [legendLayer2],

titleText: customHeader,

scalebarUnit: "Feet"

};

}

else {

if (legendLayer1.subLayerIds.length == 0 && legendLayer2.subLayerIds.length == 0 && legendLayer3.subLayerIds.length > 0) {

template.layoutOptions = {

legendLayers: [legendLayer3],

titleText: customHeader,

scalebarUnit: "Feet"

};

}

else {

template.layoutOptions = {

legendLayers: [],

titleText: customHeader,

scalebarUnit: "Feet"

};

}

}

}

}

}

}

}

template.preserveScale = printToScale;

template.outScale = customScale;

var params = new PrintParameters();

params.map = map;

params.template = template;

printTask.execute(params, getPrinted, getPrintError);

function getPrinted(evt) {

window.open(evt.url);

$(document.body).css({ 'cursor': 'pointer' });

map.setMapCursor("pointer");

}

function getPrintError(evt) {

alert(evt);

$(document.body).css({ 'cursor': 'pointer' });

map.setMapCursor("pointer");

}

 

Outcomes