Print Footer issues

Wouldn’t that be in PageInfo.Viewport, in view coordinates? Or PageInfo.ViewportBounds in model coordinates.

How do I access it as the PrintManager doesn’t have a property? When I create a new object everything is 0

I was assuming you were using a Binding converter. I don’t know if that will work or not.

Well, currently I’m simply trying to set the PrintManager’s margin in code right before calling the print method. If I used a binding in Xaml in combination with a binding converter, what would I bind the margin to? How does the print manager actually get the page size?

I was suggesting an alternative approach where you didn’t set PrintManager.margin before printing, but instead as each page is measured and arranged, using the PageInfo information.

So … pass the PageInfo as parameter to a binding converter for the print manager’s margin? I assume it doesn’t matter to what I actually bind the margin to?

<go:Diagram.PrintManager>
  <go:PrintManager Scale="NaN"
                   ForegroundTemplate="{StaticResource PrintTemplate}"
                   PageOptions="Full"
                   Margin="{Binding Path=Whatever, Converter={StaticResource PrintMarginConverter}, ConverterParameter=Viewport}"/>
</go:Diagram.PrintManager>

But wouldn’t that actually get called when the xaml gets parsed before displaying it on the screen? The question is: when will the page to print onto be measured and arranged? And how can I hook into that code to manipulate the margin?

No, what I was suggesting won’t work,

I think the right place to change how the arrangement of each page is done is inside an internal class that implements DocumentPaginator, in a method that overrides DocumentPaginator.GetPage. I don’t think you can override any methods on that class, so I don’t think you are able to implement what you want unless you try to guess on the appropriate PrintManager.Margin. Sorry.

Thank you for your help. I tried a completely different approach, which seems to work out well and I’ll describe it here if someone else has the same problem and stumbles accross this post.

At first I used a printing template with nothing but a blue rectangle on it and set this to a fixed size. Then I played with the numbers of width and height until the rectangle was exactly the size of the pdf page. Then I added margin to the printtemplate the way I needed it in the end and subtracted that from the rectangle. From the resulting rectangle size I calculated a ratio for the image size of the diagram on the pdf. Now, before I do the actual printing I save the current diagram bounds and recalculate them according to the ratio calculated earlier. Then I print and later on reset the bounds to the previously stored value.

Imagine I have a rectangle size of 500 to 1000px (that is ratio = 0.5) and my diagram bounds are (0,0,500,500) I recalculate the upper left point of the diagram bounds to -250/0 and the size to 1000/500. That means my actual diagram content is centered within the new bounds now.

If it doesn’t work you might also want to set the diagram panel’s FixedBounds or take a look at it’s Scale and adjust that. If your diagram has to be centered vertically rather than horizontally (or both) you do the same but adjust the y-position and height of the bounds. You can check what kind of centering you need if you calculate the ratio of the actual diagram’s bounds and compare that to your printing ratio, if it’s smaller you need to center vertically, horizontally if it’s larger.

Thanks for describing what you’ve done!