Scaling and centering in a print template

I’m sorry but I’m really struggling with printing…

The issue that I’m having now is that I can’t figure out a way to (refer to the screenshot below):
-Center the borders on the page (notice that they are offcentered).
-Center the drawing from the diagram on the page (notice that it’s in the upper left)
-Scale the drawing to fit the inside of the border

This is what I want it to look like but I’m having the hardest time:

This is my Print Foreground Template:


        <DataTemplate x:Key="PrintBorderTemplate">
            <Border BorderBrush="Black" BorderThickness="1" Padding="15">
                <Border BorderBrush="Black" BorderThickness="1">
                    <go:SpotPanel Name="PrintingSpotPanel">
                        <Border BorderBrush="Black" BorderThickness="1" go:SpotPanel.Alignment="BottomRight" go:SpotPanel.Spot="BottomRight" Margin="-1,-1,0,0">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="0.562*"/>
                                    <RowDefinition Height="0.438*"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="0.5*"/>
                                    <ColumnDefinition Width="0.231*"/>
                                    <ColumnDefinition Width="0.269*"/>
                                </Grid.ColumnDefinitions>
                                                        
                                <TextBlock x:Name="SketchTDYLogoText" Text="Our Company Name" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" FontSize="14" FontWeight="Bold" HorizontalAlignment="Center" Margin="4" />
                                <TextBlock x:Name="SketchDate" Grid.Row="1" Grid.Column="0" Text="{Binding Today, Source={StaticResource Static}, Converter={StaticResource Formatter}, ConverterParameter='MM/dd/yyyy'}" d:LayoutOverrides="Height" Grid.RowSpan="2" Margin="2" />
                                <TextBlock x:Name="SketchTitle" Grid.Column="1" Text="{Binding ProjectTitle, Source={StaticResource getProjectTitle}}" Grid.RowSpan="2" Grid.Row="1" Margin="2" />
                               <TextBlock x:Name="SketchPlaceHolder" Grid.Column="2" Text="Part Number" Grid.RowSpan="2" Grid.Row="1" Margin="2" />
                            </Grid>
                        </Border>
                    </go:SpotPanel>
                </Border>
            </Border>
        </DataTemplate>

and by Diagram with PrintManager stuff defined:


<go:Diagram x:Name="myDiagram" Padding="10"
            SelectionChanged="myDiagram_SelectionChanged"
        <span ="Apple-tab-span" style="white-space:pre">	</span>HorizontalContentAlignment="Stretch"
        <span ="Apple-tab-span" style="white-space:pre">	</span>VerticalContentAlignment="Stretch"
        <span ="Apple-tab-span" style="white-space:pre">	</span>NodeTemplateDictionary="{StaticResource NodeTemplateDictionary}" 
        <span ="Apple-tab-span" style="white-space:pre">	</span>AllowDrop="True"
        <span ="Apple-tab-span" style="white-space:pre">	</span>LinkTemplate="{StaticResource LinkTemplate}" 
            MinWidth="100">
    <go:Diagram.PrintManager>
        <go:PrintManager Scale="NaN" ForegroundTemplate="{StaticResource PrintBorderTemplate}"
                            PageOptions="FullGridBackground"
                            />
    </go:Diagram.PrintManager>
</go:Diagram>

Is there any way for me to get the printout to display the way I want?
I’m using Silverlight 5 and GoXam 1.3.2.5

I can look into this when I get a chance.

Basically you want to set the PrintManager.Bounds such that the visible contents are centered within that Rect. In other words, you want to make the Bounds.X and .Y smaller than the Diagram.Panel.DiagramBounds, so that there is extra space on the left and on top so that the contents appear centered on the page.

Normally, setting the PrintManager.Scale to NaN will shrink the effective scale so that a large diagram will fit within a page. However, it will not expand the scale above 1 to make a small diagram appear bigger so that it “fills” the page. So you may need to set this explicitly yourself to a value that you calculate that gets you what you want.

What confuses me about this is that isn’t the PrintManager.Bounds set after the user acknowledges the Print dialog box?

When I set a breakpoint on PrintManager.Bounds.X it’s equal to infinity. It’s also a read-only property so I’m not sure how I would ‘set the PrintManager.Bounds’ as you suggest.

If I could somehow retrieve the PrintManager.Bounds values before the page gets sent to printer, I would have no trouble centering and scaling. I think this is the part that I don’t understand. Thanks for your help!

I’m pretty sure that the PrintManager.Bounds property is settable.
PrintManager.Bounds documentation

I suppose you could override DoPrint, but I’m not sure that helps, since even that might be too early in the printing process.