Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Any examples of how to print a map using the JSAPI? All from the client?

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

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.

share|improve this answer
    
Looks good. Next obvious question - when do we get ArcGIS Server 10.1? –  Stephen Lead Dec 14 '11 at 22:15
    
@StephenLead Some time next year... –  Derek Swingley Dec 14 '11 at 22:54
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.