Print PDF with labels

4256
4
Jump to solution
03-26-2015 01:42 PM
JssrRR
by
Occasional Contributor II

Hi,

I have a feature layer showing nursing facilities and I have added label layer that show Facility IDs. I need labels only for the map printout, I do not want the labels on the map, because I already have hover over function to identify the features. I had set scale dependency on (commented out) the labels but that did not work because what I want is for the nursing facilities ID should show on the print out at any scale, so the facility IDs need to show up on the printed map regardless of scale or zoom level.

I am trying to find out if there is a way to have labels show up only when the print function is turned on or have way for the labels to be included in the PDF printout. I looked at samples and reference for label layer and label class and could not much to help me.

It will be great if I can get some help or pointers on how get this accomplished.

Thanks for the help!!

1 Solution

Accepted Solutions
ChristopherTotty
New Contributor III

You will use a PrintTask, passing in your Map object.  Before calling the execute method, you can set the visibility of your LabelLayer.  The execute method takes a second parameter of a callback function that will be run when the task is complete.  In that function, you would hide your LabelLayer.  Alternatively, you could use the Deferred object returned by the execute method. (i.e. printTaskInstance.execute(map).then(function);)

Please see the PrintTask documentation:

PrintTask | API Reference | ArcGIS API for JavaScript

View solution in original post

4 Replies
SteveCole
Frequent Contributor

Couldn't you just make your label layer visible at the very beginning of your print process (click event of your print button) and then turn it back off using the printTask's "complete" event?

JssrRR
by
Occasional Contributor II

Thanks, Steve for your suggestion, I would need a little more than that, may be an example or some references that can help me with this.

0 Kudos
ChristopherTotty
New Contributor III

You will use a PrintTask, passing in your Map object.  Before calling the execute method, you can set the visibility of your LabelLayer.  The execute method takes a second parameter of a callback function that will be run when the task is complete.  In that function, you would hide your LabelLayer.  Alternatively, you could use the Deferred object returned by the execute method. (i.e. printTaskInstance.execute(map).then(function);)

Please see the PrintTask documentation:

PrintTask | API Reference | ArcGIS API for JavaScript

JssrRR
by
Occasional Contributor II

Christopher,

Thank you for your help, used printer function to turn the visibility of label layer on and then turning if off when print task complete, works great!

0 Kudos