Select to view content in your preferred language

Silverlight Printing Issues

3451
2
12-13-2011 12:20 PM
AdamFeidt
Occasional Contributor
I'm use the printing example created by dbroux which can be found at this link in a couple applications I've developed.  I use it pretty much out of the box with the exception of the map templates.  In both scenarios the printer is acting very inconsistent.  About half the time it runs through it's natual progressions, but never hits the EndPrint, and never sends the output to the printer or print driver.  It seems to stall and the printer just continues to spool.  I know this is vague, but I'm not sure even where to start debugging.  My mainpage print control is below.  I will attach my MapPrinter.xaml and my MapPrinterDialog.xaml.  Any thoughts on where to start?  I'm using a custom County Projection in Feet.

Here is my Print Control:
        <!-- Print Map Window -->
        <userControls:DraggableWindow IsOpen="{Binding ElementName=btnTogglePrint, Path=IsChecked, Mode=TwoWay}" x:Name="PrintPanel" Grid.Row="1"
                                      VerticalAlignment="Center" HorizontalAlignment="Center" Width="340" Height="405" IsDraggable="True" IsHeightResizeable="False" IsWidthResizeable="False" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                                      Padding="0" HorizontalContentAlignment="Stretch" IsHeaderVisible="True"
                                      VerticalContentAlignment="Stretch">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Foreground="White" FontSize="12" Text="Page Style : " TextWrapping="NoWrap" VerticalAlignment="Center" />
                    <ComboBox Name="comboPrintStyle" SelectionChanged="comboPrintStyle_SelectionChanged" IsEnabled="True" Margin="5,2" MinWidth="80" SelectedIndex="0" VerticalAlignment="Center">
                        <ComboBox.Items>
                            <sys:String>Portrait_8.5x11</sys:String>
                            <sys:String>Landscape_8.5x11</sys:String>
                        </ComboBox.Items>
                    </ComboBox>
                </StackPanel>
                <!--<printer:MapPrinterDialog x:Name="MapPrinterDialog" Background="{StaticResource BaseColor}" Grid.Row="1">
                    <printer:MapPrinter x:Name="mapPrinterWithDialog" Map="{Binding ElementName=Map}" Title="Map" PageChanged="mapPrinter_PageChanged" IsScaleFixed="False" IsActive="{Binding ElementName=btnTogglePrint, Path=IsChecked }" MapUnits="Feet"/>
                </printer:MapPrinterDialog>-->
                <printer:MapPrinterDialog x:Name="MapPrinterDialog" Background="{StaticResource BaseColor}" Grid.Row="1">
                    <printer:MapPrinter x:Name="mapPrinterWithDialog" Map="{Binding ElementName=Map}" Title="Park Map" PageChanged="mapPrinter_PageChanged"
                           IsScaleFixed="False" Scale="72000" IsActive="{Binding ElementName=btnTogglePrint, Path=IsChecked }"/>
                </printer:MapPrinterDialog>
            </Grid>
            <userControls:DraggableWindow.ContentTitle>
                <StackPanel Orientation="Horizontal">
                    <Image Source="Images/i_print.png" HorizontalAlignment="Left" VerticalAlignment="Center" Width="20" Height="20"/>
                    <TextBlock Foreground="White" FontSize="12" HorizontalAlignment="Left" VerticalAlignment="Top" Text="Print" Margin="5,0,0,0"/>
                </StackPanel>
            </userControls:DraggableWindow.ContentTitle>
        </userControls:DraggableWindow>
0 Kudos
2 Replies
by Anonymous User
Not applicable
Original User: nschmidt

I too use the same printing code more or less oob (it is a great sample) and I am having the exact same issue. Did you ever figure out a solution?

I can  replicate it and fix it on demand:

To replicate:
Have a map with one tiled and one dynamic layer.
Zoom to an area and print. If successful, close the app reopen and print same extent
Print spools eternally, never prints, end print never called

To fix:
Clear ie cache and try to print again
This works for me every time.

Not a viable solution for our clients though so I continue to fiddle with the code to get it working ALL the time.
0 Kudos
AdamFeidt
Occasional Contributor
No, I have not fixed the issue.  As you can see there hasn't been much interest in my thread. 🙂   Although, you are exactly right.  Until now I couldn't replicate or fix the issue.  Thank you so much for posting.  At least now I have something to look into.  FYI...I could not replicate the issue in Google Chrome.  I have since switched to Google Chrome, but our user base has not, so the issue still persists.  We also see distortions and color blending, which most likely is a printer/network issue.  All-in-all we are struggling with the Silverlight printing.  If I figure anything out, I'll be sure to post.

Adam
0 Kudos