Select to view content in your preferred language

Printing functionality

630
4
07-15-2010 07:26 AM
SeanDangers
New Contributor
Hi,

If I want to add hard copy print functionality to my Silverlight map application, what can I do?

I know there are printing classes in SL4 but does ESRI have anything in their API as well (more specific to printing maps)?

Thanks,
Sean
0 Kudos
4 Replies
LisaChesley
Emerging Contributor
Good afternoon, Sean!

I've been able to print maps just using the tools in Silverlight 4.  There are no special ESRI functions for printing that I'm aware of.

I have a sample project that just does printing, if you'd like to have a look.  I tried to upload it, but even zipped up it appears to be a bit too big.

Reply with an email address I can reach you at, and I'll fire over the project.

Thanks!

Lisa Chesley
0 Kudos
RobertBurke
Esri Contributor
There was a small blog about printing Here:
http://blogs.esri.com/Dev/blogs/silverlightwpf/archive/2010/05/04/Take-advantage-of-new-Silverlight-...

Here is what I did to add a print button to an existing app:

Start with a working map app
Drag in a button from the toolbox into the XAML design view.
Double-click on the button in design, which stubs Click and takes you to the C#

Add a using statement:
using System.Windows.Printing;

Add this code to the button�??s Click event:
PrintDocument doc = new PrintDocument();
doc.PrintPage += (s, x) =>
{ x.PageVisual = MyMap; x.HasMorePages = false; };
doc.Print("Map");
       
Make sure your XAML map name is MyMap.

Run the app
Click the new button
Click Preferences and pick Landscape
Click ok
Pick a printer
Click Print

Thanks,
Rob Burke
Esri Redlands - Instructor
Rob Burke
0 Kudos
SeanDangers
New Contributor
Thanks for the replies.
I have now got your print sample to work, thanks!

What if I want to do some more advanced printing with templates and better resolution?
I guess I can create a new usercontrol that would work as a template and either pass in services, extent etc from the map or just grab the image from the map and stick in to a user control?
0 Kudos
FengLin
Emerging Contributor
Is it possible to print to PDF file, instead of printing to printer?
0 Kudos