Printing: bottom cut off

Hi,

I’m getting into printing and using following code (nothing Special), the bottom border of the bottom-most node is cut off (printed to XPS and PDF with the same result).

Any idea?

private void OnToolStripButtonPrintClick(object sender, EventArgs e)
{
	//this.diagram.PrintManager.Parts = this.diagram.SelectedParts;
	var printDialog = new PrintDialog();
	var dialogResult = printDialog.ShowDialog();
	if (dialogResult.Value)
	{
		this.diagram.PrintManager.Print(printDialog);
	}
}

That is unusual behavior. I cannot recall anyone who has ever had that problem.

Have you set or bound the PrintManager.Bounds? Or set the PrintManager.Margin to have a negative thickness at the bottom?

No. I did neither.

The code snippet I posted is the only thing I did with the PrintManager. I also didn’t change the templates (guess it’s using the default).

Don’t know what else could be special. The diagram is hosted in a Win Forms application. I defined a user control for it. Its embedded in a grid together with an overview and an additional text block (I want to use for displaying some context sensitive help Messages for the user). Copied most of the overview code from the Org Chart static example, but placed in on the bottom right.

Here is some additional code I use for the initialization:

diagram = goDiagramUserControl.LayoutRoot.FindName("Diagram") as Diagram;
var layout = new LayeredDigraphLayout { Direction = 90, SetsPortSpots = false };
layout.Conditions -= LayoutChange.NodeAdded;
layout.Conditions -= LayoutChange.LinkAdded;
diagram.Layout = layout;
diagram.AllowDrop = true;
diagram.IsReadOnly = false;
diagram.AllowEdit = true;
diagram.AllowScroll = true;
//diagram.HorizontalContentAlignment = HorizontalAlignment.Center;
diagram.InitialDiagramBoundsSpot = Spot.MiddleTop;
diagram.InitialPanelSpot = Spot.MiddleTop;
diagram.DragSelectingTool = null;

Any other idea?

Thanks in advance,
Marc

One thing I just noticed. It has something to do with the Expander in the nodes. If I collapse the Expander of the bottom most node, the diagram fits into the document as expected. But if the Expander is expanded, it doesn’t. Is the height of the diagram/Panel perhaps not increased when the my node is expanded? And how could I fix this?

Maybe the node template might be of interest?

<!-- template for optional nodes -->
<DataTemplate x:Key="OptionalNode">
	<go:SpotPanel Style="{StaticResource SpotPanelStyle}"
		go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"                     
		MouseEnter="Node_MouseEnter" MouseLeave="Node_MouseLeave">
		<go:NodePanel Background="{Binding Path=Node.IsSelected, Converter={StaticResource theSelectedBrushConverter}}">
			<Border BorderThickness="1" Padding="0,0,0,0" CornerRadius="3">
				<Border.BorderBrush>
					...
				</Border.BorderBrush>
				<StackPanel MinWidth="100" Width="150"
						MinHeight="50"
						Name="GoStackPanel">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="*"/>
							<ColumnDefinition Width="Auto"/>
						</Grid.ColumnDefinitions>
						<TextBlock Grid.Column="0" Grid.ColumnSpan="2" FontSize="11" FontWeight="Bold" Text="{Binding Data.Label}" TextAlignment="Center" VerticalAlignment="Center"/>
						<Image Grid.Column="1" HorizontalAlignment="Right" Width="20" Height="20" 
						   ...
						</Image>
					</Grid>
					<TextBlock FontSize="11" FontWeight="Bold" Text="{Binding ...}" TextAlignment="Center" />
					<Expander IsExpanded="{Binding Data.IsExpanded}" Visibility="...">
						<ListView ItemsSource="{Binding ...}">
							<ListView.ItemTemplate>
								<DataTemplate>
									<TextBlock FontSize="10" Text="{Binding Label}"/>
								</DataTemplate>
							</ListView.ItemTemplate>
						</ListView>
					</Expander>
				</StackPanel>
			</Border>
		</go:NodePanel>
	</go:SpotPanel>
</DataTemplate>

I assume the expanded node appears properly on screen at the time the user invokes your print command.

Could you check the Diagram.Panel.DiagramBounds at the time the PrintManager is about to be called? Hopefully the value when the node (Expander) is collapsed is smaller than the value when the node is expanded.

And the difference should be about the amount of difference. So expanding a node that is not at or near the bottom edge of the diagram bounds should not have any problems printing.

Hello Walter,

yes, the expanded node appears properly on Screen.

But the DiagramBounds values are the same when I call the PrintManager, namely

{19;10;387;806}
{19;10;387;806}

Initially, all nodes are expanded. When I collapse the bottom-most node, I can see, that the distance to the bottom of the Panel is larger than in its exanded state. Or otherwise round, when the node is expanded, the distance to the bottom of the Panel is smaller. Collapsing or expanding does not seem to have influence on the height of the Panel.

Perhaps one more thing to note: when I collapse/expand the node, the diagram is NOT re-layouted. If I Trigger a layout manually, the distance between the node’s bottom and the Panel’s bottom shrinks to Zero I guess (like in the inital state).

Meanwhile, I have found a workaround. If I set a padding for the go:diagram-element, the whole diagram is on the page.

Are you collapsing or expanding within a transaction? You should be.

Or if you cannot, you can call diagram.Panel.UpdateDiagramBounds(), which will queue up an update.

Hi,

I added a listener and call the diagram.Panel.UpdateDiagramBounds() method as you proposed. After a collapse/expand, the diagram Panel gets now resized. But the result is, that now in both cases the border from the bottom most node is missing. That’s not what we were hoping for :frowning:

But as already stated in an earlier post, setting a pedding works for me.