Select to view content in your preferred language

Tiled Layers skewed north west when printing with Silverlight 4

1247
8
06-28-2010 12:17 PM
LisaChesley
Emerging Contributor
Good afternoon, all!

I am developing an application using the new Silverlight API (using v2 RC right now, Silverlight 4, and Visual Studio 2010/Blend 4), and I'm experiencing some odd behaviour when printing maps.  The application consists of several cached tiled layers, only one of which is visible at any given time (different kinds of base maps, ie a standard map, several imagery maps, a zoning map, etc), and a selection of dynamic layers that can be turned on and off.

Once the user (me, at this point, as the application is not yet live) has chosen the layers they'd like turned on, they can hit a print button, and I generate a child window for them with their chosen tiled layer, and any dynamic layers they've turned on.  I also zoom this map in to the same extent the user was viewing on the big map.  At this point, all is well - the correct layers are showing in the correct places, and all is zoomed in to the correct extent.

When the user actually prints the map, though, the dynamic layers are correctly positioned, but the tiled layer is skewed to the northwest, sometimes so far that the region of the map the user originally chose doesn't show up on the printout.

I'm afraid I'm very lacking in GIS knowledge - we have a GIS group here that created the layers I'm using, and I'm building an application to showcase them.

I'm using the standard silverlight 4 printing behaviour:

PrintDocument doc = new PrintDocument();
            doc.PrintPage += (s, args) =>
                {                   
                    args.PageVisual = bMapOutline;
                    args.HasMorePages = false;
                };
            doc.Print("Map");

where bMapOutline is a border placeholder I created to hold my created map.

I can supply the code I use to construct the print preview map, and any other information that might be helpful in solving this, if you can please let me know what's useful to see.

Thanks in advance for your help!

Lisa Chesley
Web/Application Developer
The County of Oxford, Ontario, Canada
0 Kudos
8 Replies
dotMorten_esri
Esri Notable Contributor
Do you have a simple sample that reproduces this behavior?
0 Kudos
LisaChesley
Emerging Contributor
My apologies for the delay - the map layers we are using in this application are internal only, so I had to use some ESRI layers from the sample application.  Thankfully, they exhibit the same behaviours.

Please find my stripped down project enclosed.

Thanks!

Lisa Chesley
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Looks like you are closing the preview window too early.

If you move the code 'this.DialogResult = true;' to the event EndPrint : it's working well.

If you don't want to see the preview window during the print you can collapse it 'this.Visibility = Visibility.Collapsed;' -> it's still working.
0 Kudos
LisaChesley
Emerging Contributor
Wow, who knew?  You're absolutely correct, Dominique - I updated my code, and everything now prints properly.  For any curious parties, my print code now reads as follows:

PrintDocument doc = new PrintDocument();
            doc.PrintPage += (s, args) =>
                {                   
                    args.PageVisual = bMapOutline;
                    args.HasMorePages = false;
                };

            doc.EndPrint += (s, args) =>
                {
                    this.DialogResult = true;
                };

            doc.Print("Map");          

Thank you so much for your response!

Lisa Chesley
0 Kudos
GregoryDillon
Occasional Contributor
Lisa could I get a copy of your code?   I'm unable to download the attachment.   Everytime I try I get an error that its corrupt.

gdillon@abcwua.org

Greg
0 Kudos
LisaChesley
Emerging Contributor
Greg,

Project is in the mail!

Thanks!

Lisa
0 Kudos
JTessier
Frequent Contributor
Hi Lisa,
  Would you send me a copy of your print tool code as well, j@taic.net
Thanks!
J
0 Kudos
ahmadhasan
Deactivated User
can you help me to resize map to be fit with a4 size because i try to increase height and width but it does not work
0 Kudos