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?
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%...";
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");
}
Solved! Go to Solution.
Lori,
See this link for the workaround:
Bug: The PrintingTools service produces garbled or pixelated legend patches in PDF output
Lori,
See this link for the workaround:
Bug: The PrintingTools service produces garbled or pixelated legend patches in PDF output
I had exactly this problem and the link that Robert mentions solved the problem.
This problem has existed for quite some time as per link:
https://community.esri.com/thread/102930?commentID=368870#comment-368870
Robert and Michael,
Thank you both for your help!