Hi,
I am trying to print the text symbol on the map. The textsymbol is available on the map, but when we print it as PDF it's not available. Any idea why it's happening? I am using ArcGIS JavasScript APi 3.26.
The text symbol on map.
Text symbol not available in the print pdf.
Below is the code I am using for text symbol.
var symbol = new PictureMarkerSymbol(xxxxxurl+ "Images/marker/inspection-map-markers-no-status.png", 22, 22).setOffset(0, 5);
textSymbol = new TextSymbol(stop.attributes.OBJECTID);
textSymbol.setFont(font);
textSymbol.setColor(new Color([255, 255, 255]));
textSymbol.setAlign(TextSymbol.ALIGN_MIDDLE);
textSymbol.setAngle(0);
textSymbol.setOffset(1, 0);
var newGraphic = new Graphic(stop.toJson());
newGraphic.setSymbol(symbol);
graphics.add(newGraphic);
var Graphictext = new Graphic(stop.toJson());
Graphictext.setSymbol(textSymbol);
graphics.add(Graphictext);
stop.setSymbol(textSymbol);
Thanks
Aditya Kumar
Solved! Go to Solution.
@Noah-Sager @Bishrant I finally resolved it. I have changed textSymbol = new TextSymbol(stop.attributes.OBJECTID);
to
textSymbol = new TextSymbol(stop.attributes.OBJECTID.toString());
Thanks guys for the help and time. Appreciate your support.
Aditya
Hi @ADITYAKUMAR1, my hunch is that the symbol is not accessible to the print server. If it's being locally hosted, try hosting it publicly and see if that helps.
Hey @Noah-Sager Thanks for responding. I believe you are talking about the print service to be public. In my case our PrintingTools (GPServer) is hosted publically.
Thanks
Aditya
I'm talking about the symbol. This line in particular:
var symbol = new PictureMarkerSymbol(xxxxxurl+ "Images/marker/inspection-map-markers-no-status.png"
The symbol resource needs to be available to the print server. So if it's hosted locally, and the app is hosted locally, and the print server can't access the local symbol resource, then the printout would be missing those symbols. Does that make sense?
@Noah-Sager I removed the picturemarker symbol and then tried to print it. But the result is still the same.
Print result
Hmm, can you provide a simplified test app so I can test on my end? Using something like codepen would be fine.
@Noah-Sager Sorry for delayed response. I have attached a HTML file. I have tried everything its not working.
But there is a catch in this file. If you go to line number 163 textSymbol = new TextSymbol(i++); On every click the number will change and you wont get the number in the print pdf but if the same number if you make it static textSymbol = new TextSymbol("1"); then you will get the print.
My guess would be the font, check if removing font and/or changing the font-family when you constructed your font object makes a difference.
@Bishrant Thanks for responding. I tried changing the font from
var font = new esri.symbol.Font("12pt", esri.symbol.Font.STYLE_NORMAL, esri.symbol.Font.VARIANT_NORMAL, esri.symbol.Font.WEIGHT_BOLD, "Helvetica");
to
var font = new Font("20pt", Font.STYLE_ITALIC,
Font.VARIANT_NORMAL, Font.WEIGHT_BOLD,"Courier");
but the problem is still the same.
Thanks
Aditya
@ADITYAKUMAR1 You don't even have to specify the font-family as it's optional and will default to 'Serif'. Try changing that font declaration to something like this:
var font = new Font("20pt", Font.STYLE_ITALIC,
Font.VARIANT_NORMAL, Font.WEIGHT_BOLD);