Select to view content in your preferred language

Problen with the Print Task

13761
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
by Anonymous User
Not applicable
Original User: fcbassongis

@amarsden: create separate layerdefinition sections for the geometries and the labels.  If you are generating the JSON dynamically and on the fly, it will require a double iteration of the geometries and you must just change the "text" part of each label symbol.  I used a symbol renderer in my example below, but your symbology-per-symbol method should work too.

         
{
                        "layerDefinition": {
                            "name": "pointFeatures",
                            "geometryType": "esriGeometryPoint",
                            "drawingInfo": {
                                "renderer": {
                                    "type": "simple",
                                    "symbol": {
                                        "type": "esriSMS",
                                        "style": "esriSMSCircle",
                                        "color": [
                                            237,
                                            241,
                                            80,
                                            102
                                        ],
                                        "size": 6,
                                        "outline": {
                                            "color": [
                                                255,
                                                0,
                                                0,
                                                255
                                            ],
                                            "width": 1.5,
                                            "type": "esriSLS",
                                            "style": "esriSLSSolid"
                                        }
                                    },
                                    "label": "Vector Graphics: Points",
                                    "description": ""
                                }
                            }
                        },
                        "featureSet": {
                            "geometryType": "esriGeometryPoint",
                            "features": [
                                {
                                    "geometry": {
                                        "x": 2303145.7000116,
                                        "y": -3940248.4527985,
                                        "spatialReference": {
                                            "wkid": 102100
                                        }
                                    }
                                }
                            ]
                        }
                    },{
                        "layerDefinition": {
                            "name": "pointLabels",
                            "geometryType": "esriGeometryPoint"
                        },
                        "featureSet": {
                            "geometryType": "esriGeometryPoint",
                            "features": [
                                {
                                    "geometry": {
                                        "x": 2303145.7000116,
                                        "y": -3940248.4527985,
                                        "spatialReference": {
                                            "wkid": 102100
                                        }
                                    },
                                    "symbol": {
                                        "type": "esriTS",
                                        "angle": 0,
                                        "xoffset": 2,
                                        "yoffset": 4,
                                        "color": [
                                            0,
                                            0,
                                            0,
                                            255
                                        ],
                                        "text": "Vector 155",
                                        "align": "middle",
                                        "decoration": "none",
                                        "rotated": false,
                                        "kerning": true,
                                        "font": {
                                            "size": 10,
                                            "style": "normal",
                                            "variant": "normal",
                                            "weight": "normal",
                                            "family": "serif"
                                        }
                                    }
                                }
                          }
0 Kudos
AdrianMarsden
Honored Contributor
I did think of having text and points in different graphics layers, but that would be a big re-write.  Not only do I add these to the map, but I also add the definition to Local Storage, so when users go back into the map any added annotation re-appears.  I'd have to write a few extra loops within the process of retrieving the data from Local Storage.  Which I can do, but if there was an acceptance that this was a bug then I can tell the users that and hope esri fix it.
0 Kudos
by Anonymous User
Not applicable
Original User: fcbassongis

That's the only way I got it to work correctly, so IMO it is a bug.
0 Kudos
AdrianMarsden
Honored Contributor
Cool - I'll raise it with our local support desk
0 Kudos
by Anonymous User
Not applicable
Original User: Jian

The font size issue has been fixed, that means you can pass either '12pt', '12px' or the number 12, print should work for all the cases. The second issue is that when mixing text symbol with other types of symbol in the same graphics layer, the printout only picks the first symbol. This is a bug on print service side. At this point, the workaround is to separate different symbols into multiple graphics layers.
0 Kudos
AdrianMarsden
Honored Contributor
Thanks for that - could you add the bug number please, so that I can keep an eye on the release info (I'm guessing ArcGIS server is the product affected)
0 Kudos
by Anonymous User
Not applicable
Original User: v_dubey

Hi,

I am also facing same kind of problem when trying to print pictureMarkerSymbol on map. Instead of displaying the image used as pictureMarkerSymbol it shows a simpleMarkerSymol on the generated Pdf. Is it something I am doing incorrect.
0 Kudos
nakulmanocha
Esri Regular Contributor
As pointed by Jian. This issue has been logged as an ArcGIS Server Print service defect.

Here is the reference no.-[#NIM098798  PrintService not honoring different types of point symbols in the same graphics layer ]

Update:- Just found out that this is as per designed. Unfortunately,  not going to be addressed in the immediate future.

Recommended workflow:- is to separate out different types of graphics into different GraphicLayers.
0 Kudos
by Anonymous User
Not applicable
Original User: Schnoerkel

if I add  to my TS
font:{
                                "weight": "normal",
                                "style": "normal",
                                "variant": "normal",
                                "family": "serif"
}


Then the TS prints Color, Rotation, offset and size

Full code of one TS is

"symbol": {
                            "color": [0, 255, 0, 255],
                            "type": "esriTS",
                            "angle": 45,
                            "xoffset": 10,
                            "yoffset": 10,
                            "text": "my Text",
                            "align": "middle",
                            "decoration": "none",
                            "rotated": false,
                            "kerning": true,
                            "font": {
                                "size": 12,
                                "weight": "normal",
                                "style": "normal",
                                "variant": "normal",
                                "family": "serif"
                            }
       }


(ArcGis Server v 10.2.1)
0 Kudos
AshleyAbraham
Deactivated User

      textSymbol.text = dojo.number.format(gemessen.toFixed(1), {pattern: this.numberPattern}) + zeichen;     


The reason why it displays in the browser but not in the Print or PrintTask is because you are assigning a number to the textSymbol.text instead of a string! according to the API the TextSymbol.Text is a String, See https://developers.arcgis.com/javascript/jsapi/textsymbol.html#textsymbol1   When you use a number it may display in the browser but it doesn't display in print. Convert the number to a string by using .toString() and everything should work. Many of us miss this because it displays properly in the browser so we expect it to display in the print as well... but it doesn't.

Ash
0 Kudos