Text symbol not coming after print

1255
11
Jump to solution
09-30-2021 05:09 AM
ADITYAKUMAR1
Occasional Contributor III

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.

ADITYAKUMAR1_0-1633003531720.png

The text symbol on map.

ADITYAKUMAR1_1-1633003614407.png

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

0 Kudos
1 Solution

Accepted Solutions
ADITYAKUMAR1
Occasional Contributor III

@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 

View solution in original post

11 Replies
Noah-Sager
Esri Regular Contributor

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.

0 Kudos
ADITYAKUMAR1
Occasional Contributor III

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 

0 Kudos
Noah-Sager
Esri Regular Contributor

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?

0 Kudos
ADITYAKUMAR1
Occasional Contributor III

@Noah-Sager I removed the picturemarker symbol and then tried to print it. But the result is still the same.

ADITYAKUMAR1_0-1633021271477.png

 

 

Print result

ADITYAKUMAR1_1-1633021303832.png

 

0 Kudos
Noah-Sager
Esri Regular Contributor

Hmm, can you provide a simplified test app so I can test on my end? Using something like codepen would be fine.

0 Kudos
ADITYAKUMAR1
Occasional Contributor III

@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.

0 Kudos
Bishrant
New Contributor

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.

0 Kudos
ADITYAKUMAR1
Occasional Contributor III

@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  

0 Kudos
Bishrant
New Contributor

@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);

 

0 Kudos