Select to view content in your preferred language

Print TextSymbol

2270
11
01-15-2013 05:01 AM
lakshmanankrishnan
Emerging Contributor
When I have TextSymbols in a graphic layer on my map, the print task seems to give an error when I try to print the map. But when I switch off the text symbol graphic layer the print map comes out correctly. Do I have to do some tinkering to make the Text Symbol show up on the print map?

I am using ArcGIS JavaScript API 3.3 and ArcGIS Server 10.1

-lak
0 Kudos
11 Replies
HaitingHUANG2
New Contributor
Same issue here. I think this is a bug.
0 Kudos
BlairDeaver
Deactivated User
I have seen allot of forum posts on this:  http://forums.arcgis.com/threads/61448-Problen-with-the-Print-Task?highlight=print+text

Can someone advise if this is a bug or not?
0 Kudos
lakshmanankrishnan
Emerging Contributor
It looks like Print Task does not like Text Symbol graphics with attributes and infotemplates. Without them your Print Task should work fine. I spoke ESRI tech support about this and they said its a bug in their API. I hope it will be fixed soon.

Below is the bug number for tracking.
#NIM088789  Print Task cannot recognize text symbol graphics with attributes and infoTemplates.

-lak
0 Kudos
DK5
by
Deactivated User
I am having the same issue with Javascript API 3.4.  Any solution yet?
0 Kudos
AdrianMarsden
Honored Contributor
The same issue is reported here

http://forums.arcgis.com/threads/61448-Problen-with-the-Print-Task

W
ith another confirmed bug - I think someone from Esri needs to round all these threads up  - close all but one and give some answers - please!

ACM
0 Kudos
BenFousek
Deactivated User
I clear attributes and info templates before printing and reset them after.

Because graphics are objects you can set all the properties you want.

var graphic = new esri.Graphic(evt, app.anno.sym.point);
var gId = new Date().getTime().toString();
var atts = { id: gId };
graphic.setAttributes(atts);
var it = new esri.InfoTemplate();
it.setTitle('Point');
it.setContent(app.anno.itContentPoint(gId));
graphic.setInfoTemplate(it);
graphic.graphic_id = gId;
graphic.graphic_atts = atts;
graphic.graphic_it = it;
graphic.graphic_text = false;
app.map._layers.gl_anno_point.add(graphic)

When creating a graphic set the esri attributes and info template as normal but also set them as unique properties on the graphic object. This concept is extremely useful for more than graphics. I set custom properties on layers, the map, etc to accomplish a variety functionalities.

graphicsClear: function () {
    dojo.forEach(app.map._layers.gl_anno_polygon.graphics, function (g) {
        g.setInfoTemplate(null);
        g.setAttributes(null);
    });
    dojo.forEach(app.map._layers.gl_anno_polyline.graphics, function (g) {
        g.setInfoTemplate(null);
        g.setAttributes(null);
    });
    dojo.forEach(app.map._layers.gl_anno_point.graphics, function (g) {
        g.setInfoTemplate(null);
        g.setAttributes(null);
    });
    dojo.forEach(app.map._layers.gl_anno_marker.graphics, function (g) {
        g.setInfoTemplate(null);
        g.setAttributes(null);
    });
    dojo.forEach(app.map._layers.gl_anno_text.graphics, function (g) {
        g.setInfoTemplate(null);
        g.setAttributes(null);
    });
},
graphicsReset: function () {
    dojo.forEach(app.map._layers.gl_anno_polygon.graphics, function (g) {
        g.setInfoTemplate(g.graphic_it);
        g.setAttributes(g.graphic_atts);
    });
    dojo.forEach(app.map._layers.gl_anno_polyline.graphics, function (g) {
        g.setInfoTemplate(g.graphic_it);
        g.setAttributes(g.graphic_atts);
    });
    dojo.forEach(app.map._layers.gl_anno_point.graphics, function (g) {
        g.setInfoTemplate(g.graphic_it);
        g.setAttributes(g.graphic_atts);
    });
    dojo.forEach(app.map._layers.gl_anno_marker.graphics, function (g) {
        g.setInfoTemplate(g.graphic_it);
        g.setAttributes(g.graphic_atts);
    });
    dojo.forEach(app.map._layers.gl_anno_text.graphics, function (g) {
        g.setInfoTemplate(g.graphic_it);
        g.setAttributes(g.graphic_atts);
    });
}

Clear the esri attribute and info template properties before executing the print task. Then reset them at the end of the print task callback function.

This takes care of the text symbol print issue, but more important it is reducing the size of the request to the server for the print task. Sending the info template of any graphic, especially one with a custom widget, exponentially increases the request size, and for what?

The other option is a custom print task.  The problem there is you still need to clear attributes and info templates from the objects you are creating with the print task before creating the json. Six of one, half dozen of the other.
0 Kudos
JohnGravois
Deactivated User
@adrian.
these are two different bugs.
0 Kudos
AdrianMarsden
Honored Contributor
OK - this may be a noob question (sorry, too much gaming this weekend!) but what exactly do the templates do?  Is there any need to re-establish them?  Could I not simply destroy them on creation?

ACM
0 Kudos
AdrianMarsden
Honored Contributor
Ok - using the code above I got it not to error - but then I hit the second bug of it not taking any styles to the print .  Doh!

Any fixes anyone for this?

Cheers
ACM
0 Kudos