4

Any examples of how to print a map using the ArcGIS API for Javascript (JSAPI)?

All from the client?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Dec 8, 2011 at 3:21

3 Answers 3

5

Version 2.6 of the ArcGIS API for JavaScript (released today :) ) adds a print dijit and a print task. These both take advantage of ArcGIS Server 10.1 print service. A simple sample using the print dijit is also available. Note that the 10.1 service used in the sample is from a beta release of ArcGIS Server 10.1.

answered Dec 14, 2011 at 17:37
0
4

You should try a Google search for this. I tried "ArcGIS API for Javascript Printing" and the first result was the following blog entry on the ArcGIS Server Blog: ArcGIS Javascript API printing through PDF. For reference, the article specifically suggests viewing the example in the code gallery; however, on follow-up I could not find the example via the link or using their search. They also posted an example in the blog here. You could right click -> view source in your browser and examine the code yourself.

Additionally, the ArcGIS API for Javascript Basic Viewer template includes printing functionality.

answered Dec 8, 2011 at 5:25
0

Sorry, no example, but some hints on how to make high quality prints from the client with dynamic server layers. I haven't done this in JSAPI, but I've used similar techniques in Web ADF and silverlight.

The problem with client side printing is that you will only get screen resolution in your printouts unless you request a map image with higher DPI. When using dynamic layers this is possible.

The trick is to keep track of the current extent, size of map control, layer definitions and visible layers and request the same map image with a higher DPI setting. Stuff that image into an img tag with a defined size and print using your browser.

Request the map using REST or maybe the exportMapImage method of the ArcGISDynamicMapLayer can be used. Create an img tag on a new page, optionally with some headers and text, with height and width same as the map if you want to print the same extent. Set the image source to your map image, which will contain a lot more pixels than the size of the img tag and thus when printing will generate a high quality print with a defined scale.

If you have several layers and graphics, this approach soon becomes very nasty.

answered Dec 8, 2011 at 16:07

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.