Select to view content in your preferred language

Exporting to Image / PDF (running in circles)

3690
5
10-14-2011 07:05 AM
BrentStevener
Deactivated User
Is there any definitive source to look at for code to export the Silverlight map and its elements to an image or PDF? From what I see, it is a pain, and it seems like I'm running in circles looking at different code samples and examples trying to find a viable solution. Am I missing something?

I have tried various things and I'm able to save various non-map elements to an image or PDF, but as soon as I try to save the element that contains the map control, I get the WriteableBitmap access security errors since I am pulling services from other domains.

Why can I print the map using the built-in Silverlight print functionality, but not save it as an image?
0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor
This is supported in ArcGIS Server 10.1 Beta 1 and ArcGIS API for Silverlight 3.0 Beta 1. Here's a sample: http://help.arcgis.com/en/webapi/silverlight/3.0/samples/start.htm#ExportWebMap
0 Kudos
JasonCleaver
Frequent Contributor
Hello,

Instead of wainting for 10.1 and the Silverlight 3.0 API, I decided to create my own process. I would post the source-code, but I don't beleive I have the leagal authority to do so I'll do my best to explain my process;  this only works if you have access to the server hosting ArcGIS Server.

I summary here is what I did.
1.  I created a directory containg empty MXDs but with the pagelayout defined.  For example: 8x11.mxd, 11x17.mxd, etc..
2.  I created a directory with layer files matching each map service I publised.
3.  I then created a python script that accepts some parameters like, the extent of the map, the mxd name, and a JSON object of layer ids that correspond to the layers I created in step two, the array of visible layer ids, and a definition query for each layer if needed. When the script executes, it opens the appropraite mxd, loads the appropriate .lyr file(s), and then itterates to the layers in the .lyr file and sets the visiblity and definition query.  All of this data is passed to the sciprt in JSON.
4.  I published this script as a GPProcess so I can access it via the Silverlight API.
5.  On the client, Silverilght, I loop through all the layers in the map control to see which ones are visible.  If a layer is visible, I capture the ID of that layer, which corresponds to a .lyr file on the server, get the array of VisibleLayers, and the collection of LayerDefinitions. 
6.  Then I send all of this data back to the Server along with the map extent, the scale , and the pagelayout, again this matches the mxd I created in step 1.
7. The Python script attached to the GPProcess, takes this information and creates a PDF.

The challengs is creating the script and sending the data to it. 

I didn't do all of this in one shot.  I stared out by creating a simple script and exports a PDF and sends the url back to the clint.  Once I figured that out, I expanded to accepting mxd names, etc. 


Jason
0 Kudos
GeorgeShi
Emerging Contributor
This is supported in ArcGIS Server 10.1 Beta 1 and ArcGIS API for Silverlight 3.0 Beta 1. Here's a sample: http://help.arcgis.com/en/webapi/silverlight/3.0/samples/start.htm#ExportWebMap


Hi Jennifer,

Where is the PrintTask for Toolkit 2.2? I would like to use it for exporting maps into different formats?

thanks!

GS
0 Kudos
DominiqueBroux
Esri Frequent Contributor

Where is the PrintTask for Toolkit 2.2?

PrintTask is a new functionality of SL3.0 (and ArcGIS Server 10.1)
0 Kudos
AnastasiaAourik
Emerging Contributor
Hi Jennifer,

Implemented this PrintTask but it always returns e.Error Unable to complete operation.
Details:
Error executing tool.: Layer "BaseLayer": Unable to connect to map server at http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer.
Failed to execute (Export Web Map).
Failed to execute (Export Web Map Task).

Can you tell me why?

Note: The server that has ArcGIS Server installed has some weird rule that it
cannot have INTERNET access.  So when I login to that server I cannot hit
http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer.
Thus, I am suspecting that the Print Tool rest service fails on this layer because it cannot connect to it.
Can you confirm that the Print Tool must have INTERNET connections in order for it to print BaseMap layers from
arcgisonline.

Also, how can I test my Print Task using rest interface:
http://wellsgis.slb.com:6080/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Ma...

Not sure what Web Map JSON I can paste into the box before clicking Execute Task (Get)
I'd like to manual put a web map json from my internal map to at least test it out.
0 Kudos