I have a silverlight control that prints to about 1.5 pages. I’d like to try and scale to fit onto a single page.
I’m using the new Printing API in Silverlight 4.
I’ve modified the docToPrint.PrintPage handler as follows :
var renderHeight = item.RenderSize.Height;
var printableHeight = args.PrintableArea.Height;
var scale = printableHeight / renderHeight;
item.RenderTransform = new ScaleTransform()
{
ScaleX = Math.Min(1, scale), // dont zoom in
ScaleY = Math.Min(1, scale)
};
item.UpdateLayout();
args.PageVisual = item;
This just calculates the transform needed to fit to page. In fact the on-screen rendered control shrinks accordingly – but it always prints out full size.
I know Shawn Wildermuth blogged about printing – and some of the comments at least suggest that transforms don’t work for printing.
Is there a workaround for this yet? To be frank I don’t actually need printing support – but was just adding it as a bonus feature – so I’ll just have to split the page at an arbitrary point if i can’t figure this out.
Check solution on my blog:
Silverlight printing: fit to page.