Select to view content in your preferred language

Problen with the Print Task

12248
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: jonathbenz

Printing problems are some of the most frustrating problems that we experience. And these problems would be very difficult to solve and hence creats a big issue..
0 Kudos
AdrianMarsden
Regular Contributor II
Has anything changed in server 10.2..2?

I upgraded at the weekend, now ALL print requests that have text in them fail

  • Error {code: 400, message: "Unable to complete operation.", details: Array[1], log: undefined, httpCode: 400�?�}
    • _ssl: undefined
    • code: 400
    • details: Array[1]
    • httpCode: 400
    • log: undefined
    • message: "Unable to complete operation."
    • stack: (...)
    • get stack: function () { [native code] }
    • set stack: function () { [native code] }
    • __proto__: d
    Print.js:24


I'm pretty sure it was all working before 10.2.2.?
0 Kudos
by Anonymous User
Not applicable
Original User: msnook

This fixed it for me...running server 10.2.1  Thanks!
0 Kudos
MichaelSnook
Occasional Contributor III

Recommended workflow:- is to separate out different types of graphics into different GraphicLayers.

This fixed it for me...running server 10.2.1...thanks!

Update: 2016-01-28

Also, I have found that even though passing a non-string value for the text argument in the textSymbol works when displayed on the map...it won't print unless it's cast as a string in the textSymbol constructor.

0 Kudos
MatthieuThery1
Occasional Contributor

I am having an issue with this. I am using API 3.21.

Whenever I add a Graphics Layer with TextSymbols, the graphics print, but all the font styles are ignored. The font size is an integer in the JSON passed but it does not get applied at all, for example.

0 Kudos