Question about print diagram

Hi, i have a question, I want to add a text when user print de diagram, for example, the date or the name of user as footer of report.

I use this code to print:

  		this.myDiagram.CommandHandler.Print();

Is possible?

This information should be on every printing page

Have you read the section in the GoXamIntro.pdf document about Printing? It has examples of defining custom headers and footers.

Yes but not work for me.

My code is:

  <DataTemplate x:Key="PrintBorderTemplate">
  	<go:SpotPanel>
  		<!-- takes the size of each printed page -->
  		<!-- header -->
  		<TextBlock Text="{Binding Diagram.Model.Name}" FontSize="20"  go:SpotPanel.Spot="MiddleTop" go:SpotPanel.Alignment="MiddleBottom" />
  		<!-- cut marks -->
  		<Line X1="-10" Y1="0" X2="0" Y2="0" Stroke="Purple" StrokeThickness="1"  go:SpotPanel.Spot="TopLeft" go:SpotPanel.Alignment="BottomRight" />
  		<Line X1="0" Y1="-10" X2="0" Y2="0" Stroke="Purple" StrokeThickness="1"  go:SpotPanel.Spot="TopLeft" go:SpotPanel.Alignment="BottomRight" />
  		<Line X1="10" Y1="0" X2="0" Y2="0" Stroke="Purple" StrokeThickness="1"  go:SpotPanel.Spot="TopRight" go:SpotPanel.Alignment="BottomLeft" />
  		<Line X1="0" Y1="-10" X2="0" Y2="0" Stroke="Purple" StrokeThickness="1"  go:SpotPanel.Spot="TopRight" go:SpotPanel.Alignment="BottomLeft" />
  		<Line X1="10" Y1="0" X2="0" Y2="0" Stroke="Purple" StrokeThickness="1"  go:SpotPanel.Spot="BottomRight" go:SpotPanel.Alignment="TopLeft" />
  		<Line X1="0" Y1="10" X2="0" Y2="0" Stroke="Purple" StrokeThickness="1"  go:SpotPanel.Spot="BottomRight" go:SpotPanel.Alignment="TopLeft" />
  		<Line X1="-10" Y1="0" X2="0" Y2="0" Stroke="Purple" StrokeThickness="1"  go:SpotPanel.Spot="BottomLeft" go:SpotPanel.Alignment="TopRight" />
  		<Line X1="0" Y1="10" X2="0" Y2="0" Stroke="Purple" StrokeThickness="1"  go:SpotPanel.Spot="BottomLeft" go:SpotPanel.Alignment="TopRight" />
  		<!-- footer -->
  		<StackPanel go:SpotPanel.Spot="MiddleBottom"  go:SpotPanel.Alignment="MiddleTop">
  			<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
  				<TextBlock Text="{Binding Column}" />
  				<TextBlock Text="," />
  				<TextBlock Text="{Binding Row}" />
  				<TextBlock Text="; " />
  				<TextBlock Text="{Binding Index}" />
  				<TextBlock Text=" of " />
  				<TextBlock Text="{Binding Count}" />
  				<TextBlock Text=" [" />
  				<TextBlock Text="{Binding ColumnCount}" />
  				<TextBlock Text="x" />
  				<TextBlock Text="{Binding RowCount}" />
  				<TextBlock Text="]" />
  			</StackPanel>
  			<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
  				<TextBlock Text="{Binding ViewportBounds}" />
  				<TextBlock Text=" in " />
  				<TextBlock Text="{Binding TotalBounds}" />
  				<TextBlock Text=" @" />
  				<TextBlock Text="{Binding Scale}" />
  			</StackPanel>
  		</StackPanel>
  	</go:SpotPanel>
  </DataTemplate>
  				<go:Diagram x:Name="myDiagram">
  					<go:Diagram.PrintManager>
  						<go:PrintManager ForegroundTemplate="{StaticResource PrintBorderTemplate}" Margin="30 70 30 70" />
  					</go:Diagram.PrintManager>
  				</go:Diagram> 
	private void Print_Click(object sender, DevComponents.Silverlight.Controls.Eventing.RoutedEventArgsEx e)
	{
		this.myDiagram.CommandHandler.Print();
	}

Can you help me please?

What’s the problem? What behavior are you getting, and what do you want to be different?

this is the result, does not have the information that I want. For example: This

  		<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
  			<TextBlock Text="{Binding ViewportBounds}" />
  			<TextBlock Text=" in " />
  			<TextBlock Text="{Binding TotalBounds}" />
  			<TextBlock Text=" @" />
  			<TextBlock Text="{Binding Scale}" />
  		</StackPanel>

Other example:

	<DataTemplate x:Key="PrintBorderTemplate">
		<go:SpotPanel>
			<!-- takes the size of each printed page -->
			<!-- header -->
			<TextBlock Text="NOMBRE" FontSize="30"  go:SpotPanel.Spot="MiddleTop" go:SpotPanel.Alignment="MiddleBottom" />
			<!-- cut marks -->
			<!-- footer -->
		</go:SpotPanel>
	</DataTemplate>

					<go:Diagram x:Name="myDiagram">
						<go:Diagram.PrintManager>
							<go:PrintManager ForegroundTemplate="{StaticResource PrintBorderTemplate}" Margin="30 70 30 70" />
						</go:Diagram.PrintManager>
					</go:Diagram>

and the result is:

That’s very odd – it’s as if it continues to use the default PrintManager.

I just copied and pasted your DataTemplate and your Diagram.PrintManager definition into one of my apps, and here’s the result:

My guess at this time is that you aren’t defining the Diagram.PrintManager on the Diagram that you are actually using. Or that you are resetting the Diagram.PrintManager afterwards, somehow.

I have same issue. its not working my side also. I am using In-place print preview by using PreviewingPrintManager class.

Please help

That’s different. I don’t think the original poster was using PreviewingPrintManager from the EntityRelationship sample. I know that I was not using that custom PrintManager – I was using an instance of the standard PrintManager.