Welcome to ESRI Blogs

ArcGIS JavaScript API printing through PDF

PrinterA common question we received at this year's ESRI User Conference is how to print maps from the ArcGIS JavaScript API. One way to get a printable map is to export to PDF. ESRI's Rahul Ravikumar recently uploaded a sample to the Code Gallery that captures an ArcGIS JavaScript API map in a PDF, which can then be printed. He calls this sample Map2PDF.

Map2PDF is a RESTful service that prints all types of layers, including cached (or tiled) map layers, dynamic map layers, and client-side graphics. The sample includes a script PrintMap.js, which helps in serializing ‘map state’ and sends it to the web service. This service uses an open source iText PDF rendering engine to create the PDF.

The Map2PDF sample uses Java Servlet technology and can be deployed any Servlet / J2EE container including Apache Tomcat 6, IBM Websphere, Oracle Weblogic etc. Deployment instructions are included with the Code Gallery download.

Download the Map2PDF sample from the Code Gallery

See an example

Published Monday, July 27, 2009 4:23 PM by sterlingdq
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: ArcGIS JavaScript API printing through PDF

This will definitely proof to be of use. Can we use it too in ArcGIS server to print maps?
Monday, July 27, 2009 11:42 PM by Hussein

# re: ArcGIS JavaScript API printing through PDF

.NET web service version, please?
Wednesday, July 29, 2009 12:01 PM by Alic

# re: ArcGIS JavaScript API printing through PDF

Great job! Another very useful feature would be the capability to print attributes tables resulting from a query. For example, a pdf containing: - the base map - the graphic overlay (representing the query result on the map) - a dojox grid populated with the attributes Is this possible?
Thursday, July 30, 2009 8:32 AM by Alessio

# re: ArcGIS JavaScript API printing through PDF

Re: Printing Dojox Grids Although printing of tables is possible, there is no way one can maintain the exact look and feel of the dojox grid. To print a grid, one would have to deserialize the json in the dojox grid and make a PDFTable on the server side. You can extend the Map2PDF service to do this.
Thursday, July 30, 2009 10:20 AM by Rahul Ravikumar

# re: ArcGIS JavaScript API printing through PDF

Nice work with the map2pdf code. We have it working on our test site and passing it one geometry. What would the correct syntax be for to geometry features? This is for one polygon... [{'geometries' : [{'geometryType' : 'esriGeometryPolygon',"rings":[[[329,164],[400,187],[393,230],[333,229],[330,221],[326,216],[316,211],[316,201],[315,189],[322,169],[326,165],[329,164]]]}],'colors':[{"r":0,"g":169,"b":230}],'transparency': 0.5,'width':1259,'height':878}]
Tuesday, September 01, 2009 7:56 AM by Phil Thibault

# re: ArcGIS JavaScript API printing through PDF

You are right with the syntax for geometries. The coordinates for the polygon should be *screen* coordinates and not projected coordinates, as Map2PDF has no notion on projections. You can you the JavaScript API to get screen coordinates. For more information on the syntax you can also take a look at : http://orthogonal.esri.com/Map2PDF/help.html
Tuesday, September 01, 2009 9:40 AM by Rahul Ravoli,ar

# re: ArcGIS JavaScript API printing through PDF

Yes, Another very useful feature !
Friday, November 06, 2009 12:12 AM by ddphoebe

# re: ArcGIS JavaScript API printing through PDF

It is a great module, it is working fine for me, but this module not exporting to PDF identified graphic i.e those are added using this map.graphics.add(graphic). any suggestions please

Thanks

Mallesh

Friday, November 20, 2009 9:35 AM by malleshamm

Leave a Comment

(required) 
required 
(required)