Select to view content in your preferred language

Problen with the Print Task

13745
44
07-03-2012 04:42 AM
by Anonymous User
Not applicable
Original User: Schnoerkel

Hey there,

i have a problem with the PrintTask. In my applikation i add some Points to the the map as TextSymbol with angle and offset. In the Map all is displayed right. But when i use the PrintTask only little Points are displayed at the Map.

[ATTACH=CONFIG]15706[/ATTACH][ATTACH=CONFIG]15707[/ATTACH]

my code is

add the point:
var xmuss = mapPoint.x - ((mapPoint.x - this.inputPoints[this.inputPoints.length-2].x)/2);
   var ymuss = mapPoint.y - ((mapPoint.y - this.inputPoints[this.inputPoints.length-2].y)/2);   
   var winkelmuss = (Math.atan2((this.inputPoints[this.inputPoints.length-2].y - mapPoint.y), (this.inputPoints[this.inputPoints.length-2].x - mapPoint.x))*180)/Math.PI;
   
   var pt = new esri.geometry.Point(xmuss, ymuss, this._map.spatialReference);
   var textSymbol = new esri.symbol.TextSymbol();
   textSymbol.setColor(new dojo.Color([0,0,0])).setFont(new esri.symbol.Font("12pt").setWeight(esri.symbol.Font.WEIGHT_BOLD));
   var gemessen = '123';     
 
   textSymbol.text = dojo.number.format(gemessen.toFixed(1), {pattern: this.numberPattern}) + zeichen;  
   
   textSymbol.angle = 90;
   
   this.textGraphic=new esri.Graphic();
   this.textGraphic.setSymbol(textSymbol);
   this.textGraphic.setGeometry(pt);
   this._map.graphics.add(this.textGraphic);
   this.measureGraphics.push(this.textGraphic);
 
   


print:

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






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

        layoutTemplate = dojo.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 = dojo.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 = dojo.map(templateNames, function(ch) {
          var plate = new esri.tasks.PrintTemplate();
          plate.layout = plate.label = ch;   
          plate.format = "PDF";
          plate.layoutOptions = {
            "authorText": "Stadt Osnabrück Fachbereich Städtebau",
            "copyrightText": "Copyright Stadt Osnabrück",
            "legendLayers": [],
            "titleText": "Messen",
            "scalebarUnit": "Kilometers"
          };
          return plate;
        }); 
  
  
  // create the print dijit
        app.printer = new esri.dijit.Print({
          "map": app.map,
          "templates": templates,
          url: app.printUrl
        }, dojo.byId("print_button"));
   
        app.printer.startup();
      }
   
   function handleError(err) {
        console.log("Something broke: ", err);
      }







Hopeyou can Help me
44 Replies
JianHuang
Deactivated User
When creating the textMarkerSymbol, please use number, instead of string to define the font size.
For example:
new esri.symbol.Font("12pt").setWeight(esri.symbol.Font.WEIGHT_BOLD)
replace it as:
new esri.symbol.Font(12).setWeight(esri.symbol.Font.WEIGHT_BOLD)
Please let me know if this helps.
0 Kudos
by Anonymous User
Not applicable
Original User: Schnoerkel

I replaced the 12pt with 12 but it doesnt seem to solve the problem 😞 any other suggestions?

textSymbol.setColor(new dojo.Color([0,0,0])).setFont(new esri.symbol.Font(12).setWeight(esri.symbol.Font.WEIGHT_BOLD));
0 Kudos
WillCorum
Deactivated User
Any update on this issue? The suggested fix did not work for me either.
0 Kudos
by Anonymous User
Not applicable
Original User: Schnoerkel

A little update yes 🙂

i found out tha there must be an issue with the printtask in the api if the first grafic in the grafic layer a text symbol the text is displayed but not the flags. The text has also no angle...and so on.

If the first grafic is the Flag (what it is normally) the flags are displayed but not the text 😞 (only little purple points).

here is the post data to the excecute task


{
"mapOptions":{
    "extent":{
                   "xmin":431529.9483720495,
                            "ymin":5795228.0839689225,
                            "xmax":432577.7004675537,
                            "ymax":5795951.191665137,
                            "spatialReference":{"wkid":25832}
                           },
                "spatialReference":{"wkid":25832},
                "scale":3000.00000000002
                },
"operationalLayers":[{
      "id":"layer0",
                        "url":"http://MASKED/dienste/rest/services/alkis/MapServer",
                        "title":"layer0",
                        "opacity":1
                      },
                      {
                       "id":"graphicsLayer1",
                        "url":"http://MASKED/dienste/rest/services/snapping/MapServer/6",
                        "title":"graphicsLayer1",
                        "minScale":2500.000000000166,
                        "maxScale":0,
                        "layerDefinition":{
                             "drawingInfo":{
                                                "renderer":{
                                                               "type":"simple",
                                                                        "label":"",
                                                                        "description":"",
                                                                        "symbol":{
                                                                           "color":[0,0,0,0],
                                                                                    "outline":{"color":[0,0,0,0],"width":0,"type":"esriSLS","style":"esriSLSNull"},
                                                                                    "type":"esriSFS",
                                                                                    "style":"esriSFSSolid"
                                                                                  }
                                                                        }
                                                          }
                                            }
                       },
                       {
                        "id":"map_graphics",
                        "featureCollection":{
                              "layers":[{
                                                   "layerDefinition":{
                                                                 "name":"pointLayer",
                                                                                "geometryType":"esriGeometryPoint"
                                                                               },
                                                            "featureSet":{
                                                                "geometryType":"esriGeometryPoint",
                                                                            "features":[
                                                                                       
                                                                                        
                                                                                         
                                                                                        {
                                                                                         "geometry":{
                                                                                               "x":431996.2774297076,
                                                                                                        "y":5795593.6065749675,
                                                                                                        "spatialReference":{"wkid":25832}
                                                                                                        },
                                                                                            "symbol":{
                                                                                               "color":[0,0,0,255],
                                                                                                        "type":"esriTS",
                                                                                                        "angle":-30.662655357589376,
                                                                                                        "xoffset":75,
                                                                                                        "yoffset":75,
                                                                                                        "text":"367,2m",
                                                                                                        "align":"middle",
                                                                                                        "decoration":"none",
                                                                                                        "rotated":false,
                                                                                                        "kerning":true,
                                                                                                        "font":{"size":12,"weight":"bold"}
                                                                                                     }
                                                                                        },
                                                                                        {
                                                                                         "geometry":{
                                                                                               "x":431840.30524276325,
                                                                                                        "y":5795501.134515023,
                                                                                                        "spatialReference":{"wkid":25832}
                                                                                                       },
                                                                                            "symbol":{
                                                                                               "angle":0,
                                                                                                        "xoffset":6.75,
                                                                                                        "yoffset":8.25,
                                                                                                        "type":"esriPMS",
                                                                                                        "url":"http://MASKED/libraries/jsapi/3.0/jsapi/js/esri/dijit/images/flag.png",
                                                                                                        "width":18,
                                                                                                        "height":18
                                                                                                     }
                                                                                        }
                                                                                   
                                                                   
0 Kudos
JanJeske
Deactivated User
 ]}
                                                                     },
                                                                     {"layerDefinition":{"name":"polylineLayer","geometryType":"esriGeometryPolyline"},"featureSet":{"geometryType":"esriGeometryPolyline","features":[{"geometry":{"paths":[]},"symbol":{"color":[0,128,255,255],"width":2.25,"type":"esriSLS","style":"esriSLSSolid"}},{"geometry":{"paths":[[[432152.24961665197,5795686.078634911],[431840.30524276325,5795501.134515023]]],"spatialReference":{"wkid":25832}},"symbol":{"color":[0,128,255,255],"width":2.25,"type":"esriSLS","style":"esriSLSSolid"}},{"geometry":{"paths":[[[431840.30524276325,5795501.134515023],[432107.7995277518,5795334.446681648]]],"spatialReference":{"wkid":25832}},"symbol":{"color":[0,128,255,255],"width":2.25,"type":"esriSLS","style":"esriSLSSolid"}},{"geometry":{"paths":[[[432107.7995277518,5795334.446681648],[432257.0248262024,5795495.578253911]]],"spatialReference":{"wkid":25832}},"symbol":{"color":[0,128,255,255],"width":2.25,"type":"esriSLS","style":"esriSLSSolid"}}]}}]}}],"exportOptions":{"outputSize":[800,1100],"dpi":96},"layoutOptions":{"titleText":"Messen","authorText":"MASKED","copyrightText":"Copyright MASKED","scaleBarOptions":{"metricUnit":"Kilometers","metricLabel":"km","nonMetricUnit":"Miles","nonMetricLabel":"mi"},"legendOptions":{"operationalLayers":[]}}}
0 Kudos
by Anonymous User
Not applicable
Original User: vikrant327

I am having the same issue. I looked into the post going to the print service and looked points and label are combined into one point featureset of the type point and that where is causing problems.

What I am doing to solve this problem is adding separate graphic layer for points and text labels, and then it works.

Vikrant
0 Kudos
JanJeske
Deactivated User
Yeah this solve the Problem that the text or the points are not displayed. But not that it ignores every style u give to your text.

A second issue i found is that a square geometry is displayed as little square in map and that a filled geometry with an opacity has no opacity!
0 Kudos
by Anonymous User
Not applicable
Original User: drhall001

I can confirm these last two posts... and still occurring in jsapi 3.2:

1. You can get esri.symbol.TextSymbol to show up by creating another graphic layer and adding it to that layer
2. The offset and alignment are ignored on the TextSymbol
0 Kudos
mbunambuna
Emerging Contributor
Experiencing the same issue. Using the Print Widget sample, I added the following code to init:

        dojo.connect(app.map, "onClick", function(evt){
          app.map.graphics.add(new LabelGraphic("This is broken.", evt.mapPoint));
        })


and added this function:

LabelGraphic = function(text, point, data){
  data = data || {};
  return new esri.Graphic(
    new esri.geometry.Point(
      point.x,
      point.y,
      map.spatialReference
    ),
    new esri.symbol.TextSymbol(
      text,
      new esri.symbol.Font(
        14,
        data.option == "italic" ? esri.symbol.Font.STYLE_ITALIC : esri.symbol.Font.STYLE_NORMAL,
        esri.symbol.Font.VARIANT_NORMAL,
        data.option == "bold" ? esri.symbol.Font.WEIGHT_BOLD : esri.symbol.Font.WEIGHT_NORMAL,
        "Arial"
      ),
      data.fillColor ? new dojo.Color(data.fillColor) : new dojo.Color("#F00")
    )
  );
}


Clicking the map correctly adds the TextSymbol to the graphics layer, but it doesn't show in the printed map.
0 Kudos