Print task scale bar accuracy question

3734
16
Jump to solution
06-10-2013 07:52 AM
MikeKillion
New Contributor II
Hello,
I'm using the print task in v3.5 to output a pdf. The scalebar on the pdf is not accurate however, it's about 0.3 miles short when compared to section lines on the map (see attached pdf). I'm using the preserveScale = true option. I have the scalebar units set to miles, and have experimented with setting the units of the basemap as well - nothing makes an improvement.

Any thoughts?

Thanks
0 Kudos
1 Solution

Accepted Solutions
BenFousek
Occasional Contributor III
Yes. You can output in any spatial reference you would like. So if your data is in some state plane projection you can set outSpatialReference to that projection and that will be what is output.

My mistake was thinking that if I set the projection of the data frame in the template it would output in that projection, but the print task overrides it. Foolishly I didn't test that theory. Setting outSpatialReference fixed it and I'm getting accurate scales.

If outSpatialReference is not set it uses the map's projection (102100).

You may also want to set preserveScale to false if your output has different units (feet not meters); else the extent of the output will be different than the map.
var template = esri.tasks.PrintTemplate(); template.preserveScale = false;

View solution in original post

0 Kudos
16 Replies
VinayBansal
Occasional Contributor II
Try giving width, height in export options of PrintTemplate

var plate = new esri.tasks.PrintTemplate();
    plate.format = "pdf";
    plate.layout = "MAP_ONLY"; 
    plate.exportOptions = {
        width: map.width,
        height: map.height,
        dpi: 96
    };
0 Kudos
MikeKillion
New Contributor II
Setting width and height in the export options had no effect.

Here's the print function I'm currently using:

function printPDF() {
  
  var printUrl = 'http://services.kgs.ku.edu/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task';
  var printTask = new esri.tasks.PrintTask(printUrl);
        var params = new esri.tasks.PrintParameters();
        var template = new esri.tasks.PrintTemplate(); 
  
        template.layout = layout;     // layout set elsewhere
  template.format = "PDF";
        template.preserveScale = true;
  template.showAttribution = false;
  template.layoutOptions = {
   scaleBarUnit: "Miles",
   titleText: title,        // title set elsewhere
   legendLayers: []
  };
  

  params.map = app.map;
  params.outSpatialReference = sr;     // sr set elsewhere to 102100, also tried setting it to 3857
        params.template = template;

        printTask.execute(params, printResult, printError);
  
}



I don't expect it to be exact - I know our section lines aren't exactly a mile apart. But this seems way off. At a scale of about 1:72000, 2 miles on the scale bar is only about 1.5 miles on the map. Has anyone else noticed something like this? Can any ESRI folks comment?

Thanks,
Mike
0 Kudos
JohnGravois
Frequent Contributor
what is the coordinate system of your basemap?
0 Kudos
MikeKillion
New Contributor II
The basemap is the World_Topo_Map, so the spatial reference is 102100 (3857).
0 Kudos
JohnGravois
Frequent Contributor
that isn't a projection that preserves distance accurately, so it wouldn't be appropriate to display a scalebar.
0 Kudos
MikeKillion
New Contributor II
To remove the scalebar, do I have to create a custom mxd to use as a template?

Thanks
0 Kudos
JohnGravois
Frequent Contributor
no problem at all. 

it wouldn't take long to publish additional services for printing.  the steps in the tutorial explain that you are welcome to reuse (and tweak) our installed templates.

you can also feel free to navigate to the MXD template our OOTB print services utilize and remove the scalebar from that MXD if you prefer. (ex. .\Program Files\ArcGIS\Server\Templates\ExportWebMapTemplates\A3 Landscape.mxd)
0 Kudos
BenFousek
Occasional Contributor III
Mike,
Another option is to set the projection of your print task template map to that of the data if you want to keep the scale bar and have it accurate. This can cause a slightly longer print task processing time with tiled web mercator layers.
0 Kudos
JohnGravois
Frequent Contributor
Another option is to set the projection of your print task template map to that of the data if you want to keep the scale bar and have it accurate


@ben
i dont think thats actually correct.  its my understanding that the projection of the print output will be determined by the spatial reference which is passed within the WebMapJSON.
0 Kudos